title: Is it possible to go to a specific page of a viewpager from other activity?
body: <p>I'm not so good at Android but I'm working on my project. So please forgive my ignorance.</p>
  
  <p>I'm making a set of similar items with need prefenrences setting, so I made them preference fragments for each, and put those preference fragments in a viewpager, for easier use. I want to go to fragment No.1 if I clicked item No.1, then maybe fragment No.3 if I clicked on item No.3. Simply put, I want the items can link to its own preference fragment in the viewpager. The items are in MainActivity, the viewpager is in its own activity and this viewpager activity would not start as the app starts unless an item was clicked. </p>
  
  <p>I learnt that <code>viewPager.setCurrentItem(position);</code> should be used when I want to get to a specific page of a viewpager. But my items are in MainActivity, not inside the viewpager activity. I set the viewpager as static, and put <code>viewPager.setCurrentItem(position);</code> inside <code>onClick</code> method in MainActivity, but when I click a item, the app crashes. It shows error: java.lang.NullPointerException. The app had worked fine before I dicided to link those items to their own settings, and now I really have no idea...</p>
  
  <p>Could you please tell me whether it is possible to get to a specific page of a viewpager from other activity? If it is possible, how to do? Thank you so much!</p>
  
  <hr>
  
  <p><strong>Renew:</strong></p>
  
  <p>I tried to mess with the code, I changed the adapter of the viewpager into <code>protected static MyAdapter adapter;</code>. There was no crash then, but I always went to the first page of the viewpager, whichever item I clicked...</p>