I am having a specific problem with an application that has several actions. I have a screen manager associated with the service. Server polling service for data. The screen manager launches Activity A, B, or C based on the data. It will also allow the user to choose to display other activities or he can automatically change the action based on new data from the service. Currently, the entire navigation system works fine, and if the user clicks "Home", the corresponding activity returns to the foreground when the user clicks the application icon on the Android main screen or in the list of recently launched applications.
Then I had to implement a new function to display the icon and notification. At first I implemented this, only showing a notification when the actions were no longer visible, setting it in each of the onPause activities. It worked like a charm and gave the user a third option to re-display the application after pressing the "Home" button. However, if the data from the server (when the application is not displayed) forces the screen manager to update the displayed action. I'm having problems. I think that my activity stack is spinning up. Since then, I tried a slightly different model in which the screen manager processes notifications and always displays a notification, updating it with a new intent whenever activity is updated, but it still does not cut it.
When the application is minimized and data changes, I see that the screen manager calls startActivityForResult for a new action, and it looks like Android knows that we are minimized and do not display Activity. Then I can also call the screen manager call to complete the old top activity.
Currently, for each activity, the flag is set to singleTop in the manifest and FLAG_ACTIVITY_SINGLE_TOP in the code. When the data has not changed on the server, I pull the application back using any of the above, I get what I expect, and Activity onNewIntent is called. However, when the data has been changed and the user calls the application through a notification, he calls the onCreate actions. The Activity starts and starts, but then dropping it returns me to what looks like another instance of the same Activity, not an exit. I just looked carefully at my logarithm, and I see 2 calls to Activity onResume, but after that there are no doubles.
It seems to me that maybe I just missed something simple, like another flag of intent in the intention of notification? Thanks for any ideas!
android notifications
bursk Nov 08 '10 at 23:35 2010-11-08 23:35
source share