resuming an activity from a notification

前端 未结 7 2174
刺人心
刺人心 2020-11-30 12:24

I have a notification in the status bar for my app:

    Notification notification = new Notification(R.drawable.icon, null, System.currentTimeMillis());

            


        
7条回答
  •  一整个雨季
    2020-11-30 12:35

    I've solved this issue by changing the launchMode of my activity to singleTask in the androidManifest.xml file.

    The default value for this property is standard, which allows any number of instances to run.

    "singleTask" and "singleInstance" activities can only begin a task. They are always at the root of the activity stack. Moreover, the device can hold only one instance of the activity at a time — only one such task. [...]

    The "singleTask" and "singleInstance" modes also differ from each other in only one respect: A "singleTask" activity allows other activities to be part of its task. It's always at the root of its task, but other activities (necessarily "standard" and "singleTop" activities) can be launched into that task. A "singleInstance" activity, on the other hand, permits no other activities to be part of its task. It's the only activity in the task. If it starts another activity, that activity is assigned to a different task — as if FLAG_ACTIVITY_NEW_TASK was in the intent.

    you can find a detailed explanation in the Android Developers' Guide

    I hope this helps

提交回复
热议问题