How do I avoid onCreate() being called when starting an Activity?

后端 未结 5 363
难免孤独
难免孤独 2021-01-13 14:27

I want to reload an activity from stack.

I use startActivity() to start new activities. When I\'m on Activity D I want to reload Activity A

5条回答
  •  清酒与你
    2021-01-13 15:07

    1) Although I am not sure, you could try using startActivityForResult() rather than startActivity(). I believe this does not completely end the activity and start it again. I would recommend using this link in order to further read on how to implement such a method.

    2) Alternatively, when you go from activity D -> A, continue to use startActivity(), but pass in a dummy extra. Then in activity A, use an if statement:

     if(!(this.getIntent().hasExtra("dummyStringExtra")) {
      //fire the data thread here 
    }
    

    Cheers. I hope this helps.

提交回复
热议问题