Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

onNewIntent is not called in JellyBean

I see a difference in behavior of onNewIntent calls between 2.3.4 and 4.2.

I have an activity with launchMode=singleTask. According to my understanding of how singleTask works, each time when activity is restored from the task list, onNewIntent should be called.

This is what happens on 2.3.4 (LG P990) when I start an activity, press "home" to move it to foreground and then restore from task list (longpress "home"):

D/NewIntent(23314): onPause
D/NewIntent(23314): onNewIntent
D/NewIntent(23314): onResume
D/NewIntent(23314): onPause
D/NewIntent(23314): onNewIntent
D/NewIntent(23314): onResume


Same on 4.2 (Nexus 4):

D/NewIntent(12960): onPause
D/NewIntent(12960): onResume
D/NewIntent(12960): onPause
D/NewIntent(12960): onResume

As you see, onNewIntent is not called.

Can someone explain me what is going on?

like image 542
lstipakov Avatar asked Nov 02 '22 21:11

lstipakov


2 Answers

I had the same issue with a Galaxy Nexus on 4.2.2. The code was developed on an emulated Nexus S (API 15). I ended up moving the logic from onNewIntent() to onResume().

like image 171
Kolkoltan Avatar answered Nov 14 '22 22:11

Kolkoltan


During my headaches whilst trying to solve this dilemma Re-showing-a-singletask-activity I had to create a "middle man" -- i.e. a separate (Self) IntentService which would receive a Bundle via its onHandleIntent method, and then immediately fire off a new intent (to your singleTask Activity).

I have just tested on devices running 2.3.7 and 4.1.2 - onNewIntent called on singleTask activity every time.

hth

like image 28
CoastalB Avatar answered Nov 15 '22 00:11

CoastalB