How to prevent custom home launcher app restart activity?

前端 未结 2 1649
我寻月下人不归
我寻月下人不归 2020-12-17 03:19

I am working on my own home launcher replacement and it works fine but one thing bothers me. When I press a home key, current home activity (the one defined in manifest as m

相关标签:
2条回答
  • 2020-12-17 03:52

    Add

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

    to the onCreate() of your first Activity (see Android application restarts when opened by clicking the application icon).

    0 讨论(0)
  • 2020-12-17 04:02

    Add android:launchMode="singleInstance" to your <activity> element in the manifest.

    0 讨论(0)
提交回复
热议问题