title: how to go to next activity after ViewPager in android?
body: <p>I created a "Slide Image" in first activity; which has five images. After I slide the last image(fifth), it should go to next activity,say-activity_next.xml.</p>
  
  <p>Below is my code to slide Image i.e., SlideActivity.java</p>
  
  <pre><code>public class SlideActivity extends Activity {
  
      public void onCreate(Bundle savedInstanceState){
           super.onCreate(savedInstanceState);
           setContentView(R.layout.activity_main);
  
           ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
           ImagePagerAdapter adapter = new ImagePagerAdapter();
           viewPager.setAdapter(adapter);  
  
      }
  
       private class ImagePagerAdapter extends PagerAdapter {
              private int[] mImages = new int[] {
                  R.drawable.one,
                  R.drawable.two,
                  R.drawable.three,
                  R.drawable.four,
                  R.drawable.five
              };
  
      @Override
      public int getCount() {
      return mImages.length;
      }
  
      @Override
      public boolean isViewFromObject(View view, Object object) {
      return view == ((ImageView) object);
          }
  
       @Override
       public Object instantiateItem(ViewGroup container, int position) {
         Context context = Illustrations.this;
         ImageView imageView = new ImageView(context);
         int padding = context.getResources().getDimensionPixelSize(
                R.dimen.padding_medium);
         imageView.setPadding(padding, padding, padding, padding);
         imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
         imageView.setImageResource(mImages[position]);
         ((ViewPager) container).addView(imageView, 0);
         return imageView;
        }
  
  }
  }
  </code></pre>
  
  <p>I'm not getting where to pass Intent for next activity i.e., <code>activity_next.xml</code></p>
  
  <p>**** UPDATED CODE as per your suggestions ****</p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState){
           super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
  
    final ViewPager viewPager = (ViewPager) findViewById(R.id.view_pager);
       ImagePagerAdapter adapter = new ImagePagerAdapter();
       viewPager.setAdapter(adapter);  
  
  
  
    viewPager.addOnPageChangeListener(new ViewPager.OnPageChangeListener() {
  
          @Override
          public void onPageSelected(int position) {
              // TODO Auto-generated method stub
           if(position==viewPager.getAdapter().getCount()){
      Intent reg = new Intent(SlideActivity.this,activity_next.class);
                  startActivity(reg);
              }
          }
  
          @Override
          public void onPageScrolled(int arg0, float arg1, int arg2) {
              // TODO Auto-generated method stub
  
          }
  
          @Override
          public void onPageScrollStateChanged(int arg0) {
              // TODO Auto-generated method stub
  
          }
      });
  
  
      }
  
          private class ImagePagerAdapter extends PagerAdapter {
          private int[] mImages = new int[] {
              R.drawable.one,
              R.drawable.two,
              R.drawable.three,
              R.drawable.four,
              R.drawable.five
          };
  
        @Override
        public int getCount() {
        return mImages.length+1;
        }
  
        @Override
        public boolean isViewFromObject(View view, Object object) {
        return view == ((ImageView) object);
         }
  
           @Override
       public Object instantiateItem(ViewGroup container, int position) {
       Context context = Illustrations.this;
       ImageView imageView = new ImageView(context);
       int padding = context.getResources().getDimensionPixelSize(
            R.dimen.padding_medium);
       imageView.setPadding(padding, padding, padding, padding);
       imageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
       if(position &lt; getCount()-1)
       imageView.setImageResource(mImages[position]);
       ((ViewPager) container).addView(imageView, 0);
       return imageView;
     }
  
  
  
  
      @Override
      public void destroyItem(ViewGroup container, int position, Object   object) {
        ((ViewPager) container).removeView((ImageView) object);
      }
   }
   }
  </code></pre>
  
  <p>****activity_next.java code is below ****</p>
  
  <pre><code>public class activity_next extends Activity{
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_next);
  }
  
  }
  </code></pre>
  
  <p>**** activity_next.xml code is as below****</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" &gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Welcome to Nowhere Else" /&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>