Android, How to call onCreate () explicitly from another method?

I want to call onCreate (Bundle cicici); from another method, then I get a "NullPointerException", so please call me, how can I call onCreate () from another method ().

public void moreFriendsButtonClick(int id) { contentId= id; onCreate(tempBundle); } 

Here I pass the value of int and

 tempBundle=savedInstanceState; 

and after that I get a NullPointerException

+7
source share
2 answers

you need to create the package again. savedInstanceState is local to the onCreate method. try

 tempBundle = new Bundle(); onCreate(tempBundle); 

It should work.

+4
source

This is what worked for me:

 onCreate(new Bundle()); 
+1
source

All Articles