Activity Lifecycle Question

by Gil » Mon, 29 Sep 2008 05:56:38 GMT


Sponsored Links
 I have an activity which is started by the intent set by my app in the
status bar. My activity uses the singleTop launchMode. I go through
the following sequence of events:

1) My activity is initially not visible.
2) I get a notification in the status bar. I click on the new
notification which starts my activity.
3) While my activity is still visible I get a new notification in the
status bar. I click on the new notification again.

My question is the following: What method should I override to learn
that my activity is being "started" when the user clicks on the
notification the second time?

I thought that onNewIntent should be called but it is not. onNewIntent
does get called each time I click on the notification if my activity
is initially started from the home screen (but not if it is initially
started by clicking on the notification).

--~--~---------~--~----~------------~-------~--~----~



Activity Lifecycle Question

by Megha Joshi » Mon, 29 Sep 2008 08:51:50 GMT


 When setting the Notification intent, are you using the Flags CLEAR_TOP and
SINGLE_TASK?
ie. Intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK)

More explanation about these launch modes is given in the docs below:
 http://code.google.com/android/reference/android/content/Intent.html #FLAG_ACTIVITY_CLEAR_TOP

2008/9/28 Gil <[EMAIL PROTECTED]>


--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


Activity Lifecycle Question

by Gil » Mon, 29 Sep 2008 10:12:09 GMT


 Awesome! You saved the day ... again.
--~--~---------~--~----~------------~-------~--~----~



Activity Lifecycle Question

by Guillaume Perrot » Mon, 29 Sep 2008 18:54:24 GMT


 "A situation you will often run in to is when another entity (such as
the SearchManager or NotificationManager) starts one of your
activities. In this case, the Intent.FLAG_ACTIVITY_NEW_TASK flag must
be used, because the activity is being started outside of a task (and
the application/task may not even exist). As described previously, the
standard behavior in this situation is to bring to the foreground the
current task matching the new activity's affinity and start the new
activity at the top of it. There are, however, other types of behavior
that you can implement.

One common approach is to also use the Intent.FLAG_ACTIVITY_CLEAR_TOP
flag in conjunction with NEW_TASK. By doing so, if your task is
already running, then it will be brought to the foreground, all of the
activities on its stack cleared except the root activity, and the root
activity's onNewIntent(Intent) called with the Intent being started.
Note that the activity often also use the singleTop or singleTask
launch mode when using this approach, so that the current instance is
given the new intent instead of requiring that it be destroyed and a
new instance started."

from  http://code.google.com/android/intro/appmodel.html 



--~--~---------~--~----~------------~-------~--~----~



activity lifecycle question

by Rico » Wed, 03 Feb 2010 04:15:39 GMT


 I have a question about working with the activity lifecycle in
Android.

Let's suppose my app has some music playing.

I want the music to continue playing in the following scenarios:
- User changes screen orientation
- User browses different activities within my app

I want the music to stop playing in the following scenarios:
- User presses home button
- Another app comes to the foreground (e.g. Google talk message comes
in and user chooses to reply, or user presses call-button to launch
dialer app, or user presses camera button to launch camera app, etc.)

What's the cleanest way to accomplish this?

Thanks for reading and any help you can offer.

--



activity lifecycle question

by Aniruddh Bajirao » Wed, 03 Feb 2010 04:29:45 GMT


 >From the requirements that you mentioned, it seems to me that you need to
handle the onPause() ... (for the case when ur app is swapped out or another
app is on the screen), onResume(), onStop() and use the
OrientationEventListener (onOrientationChanged)
For the music player though, it might make sense to have a service.





>



Other Threads

1. AdSense for Mobile Apps

Just wondering if anyone else here is participating in AdSense for
Mobile Apps beta. As far as I know, there is no dedicated list for
devs currently using the program. I'd be interested in comparing notes/
strategies. Anyone else interested and enrolled in the beta?
--~--~---------~--~----~------------~-------~--~----~

2. Motorola Cliq Review

So guys here are the Motorola Cliq Review via Engadget [http://bit.ly/uLXrO]
and via Gizmodo [http://bit.ly/eG8eB]Looks good and a decent replacement for
your G1... :P

tp gw keknya ttp nunggu si Sholes aja ahhh... :P

--~--~---------~--~----~------------~-------~--~----~
Google Groups "Indonesian Android Community [id-android]" group.

To post to this group, send email to id-android@googlegroups.com

To request to subscribe to this group, please visit the following page:
 

3. Kernel Compile Error : error: asm/arch/mm.h

4. Bug in dalvik? Application will not load on package change

5. Ada yg bs bantu root magic ga?utk daerah bandung!ada master android bdg ga?

6. Ada yg bs bantu root magic ga?utk daerah bandung!ada master android bdg ga?

7. Posting lost