Android application restarts when opened by clicking the application icon Android application restarts when opened by clicking the application icon android android

Android application restarts when opened by clicking the application icon


Problem:

I'm not qualified to say this a bug, but there is a behaviour with release builds when starting the application from the launcher. It seems that instead of resuming the previous Activity, it adds a new Activity on top. There is a related bug report on this topic here.

Solution:

I'm working around this this by closing the Launcher Activity if it's not the root of the task, as a result the previous Activity in that task will be resumed.

if (!isTaskRoot()) {    finish();    return;}


Issue for me was whenever app in installed by an apk with the click on 'Open' option it used to relaunch every time when we minimize it.

resolved it by

SplashActivity.java:

 override fun onCreate(savedInstanceState: Bundle?) {        super.onCreate(savedInstanceState)        if (!isTaskRoot            && intent.hasCategory(Intent.CATEGORY_LAUNCHER)            && intent.action != null            && intent.action.equals(Intent.ACTION_MAIN)) {            finish()            return        }}