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. Advanced Medialets Question...

For those who've used medialets - having a problem dynamically setting
the ap_id.

I have a couple of apps that use an android Library. Medialets uses an
"app_id" string in the strings.xml of the app. All of the
functionality for the ads is in the Library code (see below), but each
app needs to have its own unique medialets app id.

Here's how the app is laid out:

App1 - MainActivity.class -> extends Activity, sets up some
parameters, starts the Library's main activity and finishes.
App1's strings.xml has the medialets app_id.

Library - LibraryActivity.class -> extends an abstract Medialets
wrapper class, and runs a method of that class to initiate the ads.
Library - Medialets wrapper class -> extends AdManager (Medialets)

Here's the problem - if the Library does not have a proper medialets
app_id in its strings.xml, the ads fail. As soon as I make sure it has
a proper app_id, it works fine.

The Android docs make it very clear that when using a Library,
conflicting files are "merged" with the Library and the class using
the Library always overrides. When I debug Medialets, I can in fact
confirm that the proper key is being sent to them. But sure enough,
unless a proper app_id is IN the Library's strings.xml, the ads do not
work.

Any thoughts?

-- 

2. Implementing "Guild" IM client

I'm trying to figure out the best way to implement possibly hundreds
of private chat rooms for a mmo app using it's API.  The user would
just enter their API "key" which would provide the guild ID. All users
with the app that have that guild ID would automatically be put in a
chat group and then be able to IM as a standard IM client.

I know this could turn into ALOT of data, so I'm wondering what
network protocols I would use that would be 1) Least amount of server-
side objects needed 2) Most efficient from the user's perspective.

Anyone have any suggestions?

Thanks a bunch

Wes Eklund

-- 

3. Android widget--table display

4. problem with asyntask

5. URLConnection & Verizon 3G

6. SecurityException: Permission Denial

7. fetching the nearest n results from google maps api in android