Android: How do I avoid starting activity which is already in stack?

前端 未结 7 2187
一整个雨季
一整个雨季 2020-12-23 12:20

Lets try to explain my question: I got an application and a service. The application is started with activity A. The service sends a broadcast that will let the application

7条回答
  •  不思量自难忘°
    2020-12-23 13:14

    If you don't need the second activity anymore, it is good practise to finish it, then you should do this on the second activity after the operation is ended:

    startActivity(new Intent(this, FirstActivity.class).setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
    finish();
    

提交回复
热议问题