title: Android Studio start new activity from progress bar
body: <p>I created a progress and i want it to take the user to the next screen when it is done loading . I put some code in to make it go to the next screen when the progress bar is done loading but it's not working . I tried clarifying the second activity in the android manifest file but it still doesn't go to that page when it's done loading. This is the code that i wrote . If someone can give me proper code or tell me if i did something wrong , I would appreciate it very very much thanks !</p>
  
  <p>Mainactivity :</p>
  
  <pre><code>package com.example.brandon.territories;
  
  import android.content.Context;
  import android.content.Intent;
  import android.os.Bundle;
  import android.os.Handler;
  import android.support.v7.app.AppCompatActivity;
  import android.view.Menu;
  import android.widget.ImageView;
  import android.widget.ProgressBar;
  
  public class MainActivity extends AppCompatActivity {
  private ProgressBar progressBar;
  private int progressStatus = 0;
  private ImageView ImageView;
  private Handler handler = new Handler();
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      progressBar = (ProgressBar) findViewById(R.id.progressBar);
      ImageView imageView = (ImageView) findViewById(R.id.imageView);
  
      //Long operation by thread
      new Thread(new Runnable() {
          public void run() {
              while (progressStatus &lt; 100) {
                  progressStatus += 5;
                  //Update progress bar with completion of operation
                  handler.post(new Runnable() {
                      public void run() {
                          progressBar.setProgress(progressStatus);
                      }
                  });
                  try {
                      // Sleep for 300 milliseconds.
                      //Just to display the progress slowly
                      Thread.sleep(300);
                  } catch (InterruptedException e) {
                      e.printStackTrace();
                  }
              }
          }
      }).start();
  }
  
  class MyProgressBar extends ProgressBar
  {
      @Override
      public void setProgress(int progress)
      {
          super.setProgress(progress);
          if(progress == this.getMax())
          {
              //Do stuff when progress is max
              Intent intent  = new Intent(MainActivity.this, SecondActivity.class);
              startActivity(intent);
          }
      }
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items
      //to the action bar if it is present.
      getMenuInflater().inflate(R.menu.activity_main, menu);
      return true;
  }
  }
  </code></pre>
  
  <p>Android manifest :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.example.brandon.territories" &gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@mipmap/ic_launcher"
      android:label="@string/app_name"
      android:supportsRtl="true"
      android:theme="@style/AppTheme" &gt;
      &lt;activity
          android:name=".Splash"
          android:label="@string/title_activity_splash"
          android:theme="@style/AppTheme.NoActionBar" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".MainActivity"
          android:label="@string/app_name"
          android:theme="@style/AppTheme.NoActionBar" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.DEFAULT" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
      &lt;activity
          android:name=".SecondActivity"
          android:label="@string/title_activity_second"
          android:theme="@style/AppTheme.NoActionBar" &gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
          &lt;/intent-filter&gt;
  
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>