Setting FLAG_ACTIVITY_NEW_TASK for the notification Intent will cause the following:
-
If the activity is not already running in a task, a new task will be started and the Intent will be delivered to the activity in
onCreate() -
However, if the activity is already running in a task, that task will be brought to the foreground. That’s all. The Intent will not be delivered and
onNewIntent()will not be called.
If you want the Intent to actually be delivered you need to specify:
start_test.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_SINGLE_TOP);
It makes no difference whether the launchMode of the activity is singleTop or not, you still must specify Intent.FLAG_ACTIVITY_SINGLE_TOP in the Intent.
Note: If the activity is already running in a task and the activity is not on top of the activity stack in that task, the task will be brought to the foreground. That’s all. The Intent will not be delivered. The only way to make this happen would be to add Intent.FLAG_ACTIVITY_CLEAR_TOP to the other 2 flags, but this may not be what you want to happen (depends on your specific scenario).
See my (still) open issue on Google code at http://code.google.com/p/android/issues/detail?id=17137