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

前端 未结 2 914
醉梦人生
醉梦人生 2021-02-20 15:16

I want to call onCreate(Bundle cicici); from other method then i am getting \"NullPointerException\", so please guide me how can i call the onCreate() from another method().

相关标签:
2条回答
  • 2021-02-20 15:30

    you should create the bundle again. savedInstanceState is local to onCreate method. try

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

    It should work.

    0 讨论(0)
  • 2021-02-20 15:37

    This is what worked for me:

    onCreate(new Bundle()); 
    
    0 讨论(0)
提交回复
热议问题