Sending Activity to background without finishing

前端 未结 5 986
臣服心动
臣服心动 2020-12-05 14:53

How can I make an activity go to background without calling its finish() method and return to the Parent activity that started this? I tried so much but I could

5条回答
  •  不知归路
    2020-12-05 15:14

    Try:

     Intent toNextActivity = new Intent(CurrentActivity.this,
                                         NextActivity.class);
     CurrentActivity.startActivity(toNextActivity);
    

    If you use this way, the method onPause() from CurrentActivity will be called and if you have a static variable (like a MediaPlayer object) in CurrentActivity it will continue to exist (or play if it is playing)..

    I'm using that in my application but I found a better way to do that with services.

    Hope this will help you!

提交回复
热议问题