Android App Restarts upon Crash/force close

前端 未结 7 975
名媛妹妹
名媛妹妹 2020-12-07 10:10

My android app is getting restarted after force close, through my entire application which consist of 20 activities, I am relying on static data created on a main activity.

7条回答
  •  醉梦人生
    2020-12-07 10:22

    My app was also getting resumed with blank screen, when it was getting crashed. To resolve this, I checked the savedInstanceState object on onCreate method of my main activity and if it is not null (means it is restarted by android system) then I finished my activity. Something like that:

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        if (savedInstanceState != null) {
            finish();
        }
    }
    

    It may help in your case too.

提交回复
热议问题