[android-developers] Re: How to solve the problem of launch the apps twice or more?
The purpose of this app is to run the service forever until shutdown the phone, and after the user leaves the app and return later, the service will not launch again, means only have one of this service running. Now, the problem is it can't only have one of this service running. Do I need adding something in AndroidManifest.xml file, the class that extends Activity class or the class that extends Service class? On Apr 21, 1:07 pm, Dianne Hackborn hack...@android.com wrote: Starting a service doesn't have anything to do with the activity stack. It is only needed if you actually must have a service running even after the user leaves your app. (And of course you must have a good plan for how you will stop the service, so it doesn't get left running forever.) On Tue, Apr 20, 2010 at 9:05 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, Dianne Hackborn, Thank you! In the main activity, I will start a service, so I am calling startService() in onCreate(). Is that not necessary? On Apr 21, 11:25 am, Dianne Hackborn hack...@android.com wrote: Make sure you aren't calling startActivity() anywhere, such as in onCreate(). Look at the log (adb logcat) and event log (adb logcat -b events) to see what the system is saying about launching and handling activities. Please don't use singleTask or singleInstance to fix such problems, they are not needed and have other repercussions you probably don't want. On Tue, Apr 20, 2010 at 7:07 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, thank you for your help! But I tried to add android:launchMode=singleTask or android:launchMode=singleInstance in the activity before, but it seems not work. The app still running twice or more at the same time by rotate screen or press return button, and launch the app. On Apr 21, 4:38 am, ~ TreKing treking...@gmail.com wrote: On Tue, Apr 20, 2010 at 2:06 AM, Kenneth WON kenneth...@gmail.com wrote: But my expected result is just have one and only one app A launch. http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... http://developer.android.com/intl/fr/guide/topics/manifest/activity-e.. . --- -- TreKing - Chicago transit tracking app for Android-powered deviceshttp:// sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You
Re: [android-developers] Re: How to solve the problem of launch the apps twice or more?
Kenneth WON wrote: The purpose of this app is to run the service forever until shutdown the phone, and after the user leaves the app and return later, the service will not launch again, means only have one of this service running. Please don't do that. First, it's not possible: http://www.androidguys.com/2009/09/09/diamonds-are-forever-services-are-not/ Second, it's a bad idea to even try: http://www.androidguys.com/2010/03/29/code-pollution-background-control/ Now, the problem is it can't only have one of this service running. What is it? Services are natural singletons -- there is exactly 0 or 1 copy of the service running at any point. The goal is for there to be 0 copies of the service running unless it is actively delivering user-perceived value. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy _Beginning Android 2_ from Apress Now Available! -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to solve the problem of launch the apps twice or more?
Hi, thank you for your help! But I tried to add android:launchMode=singleTask or android:launchMode=singleInstance in the activity before, but it seems not work. The app still running twice or more at the same time by rotate screen or press return button, and launch the app. On Apr 21, 4:38 am, ~ TreKing treking...@gmail.com wrote: On Tue, Apr 20, 2010 at 2:06 AM, Kenneth WON kenneth...@gmail.com wrote: But my expected result is just have one and only one app A launch. http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... --- -- TreKing - Chicago transit tracking app for Android-powered deviceshttp://sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to solve the problem of launch the apps twice or more?
Make sure you aren't calling startActivity() anywhere, such as in onCreate(). Look at the log (adb logcat) and event log (adb logcat -b events) to see what the system is saying about launching and handling activities. Please don't use singleTask or singleInstance to fix such problems, they are not needed and have other repercussions you probably don't want. On Tue, Apr 20, 2010 at 7:07 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, thank you for your help! But I tried to add android:launchMode=singleTask or android:launchMode=singleInstance in the activity before, but it seems not work. The app still running twice or more at the same time by rotate screen or press return button, and launch the app. On Apr 21, 4:38 am, ~ TreKing treking...@gmail.com wrote: On Tue, Apr 20, 2010 at 2:06 AM, Kenneth WON kenneth...@gmail.com wrote: But my expected result is just have one and only one app A launch. http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... http://developer.android.com/intl/fr/guide/topics/manifest/activity-e.. . --- -- TreKing - Chicago transit tracking app for Android-powered deviceshttp:// sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to solve the problem of launch the apps twice or more?
Hi, Dianne Hackborn, Thank you! In the main activity, I will start a service, so I am calling startService() in onCreate(). Is that not necessary? On Apr 21, 11:25 am, Dianne Hackborn hack...@android.com wrote: Make sure you aren't calling startActivity() anywhere, such as in onCreate(). Look at the log (adb logcat) and event log (adb logcat -b events) to see what the system is saying about launching and handling activities. Please don't use singleTask or singleInstance to fix such problems, they are not needed and have other repercussions you probably don't want. On Tue, Apr 20, 2010 at 7:07 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, thank you for your help! But I tried to add android:launchMode=singleTask or android:launchMode=singleInstance in the activity before, but it seems not work. The app still running twice or more at the same time by rotate screen or press return button, and launch the app. On Apr 21, 4:38 am, ~ TreKing treking...@gmail.com wrote: On Tue, Apr 20, 2010 at 2:06 AM, Kenneth WON kenneth...@gmail.com wrote: But my expected result is just have one and only one app A launch. http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... http://developer.android.com/intl/fr/guide/topics/manifest/activity-e.. . --- -- TreKing - Chicago transit tracking app for Android-powered deviceshttp:// sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
Re: [android-developers] Re: How to solve the problem of launch the apps twice or more?
Starting a service doesn't have anything to do with the activity stack. It is only needed if you actually must have a service running even after the user leaves your app. (And of course you must have a good plan for how you will stop the service, so it doesn't get left running forever.) On Tue, Apr 20, 2010 at 9:05 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, Dianne Hackborn, Thank you! In the main activity, I will start a service, so I am calling startService() in onCreate(). Is that not necessary? On Apr 21, 11:25 am, Dianne Hackborn hack...@android.com wrote: Make sure you aren't calling startActivity() anywhere, such as in onCreate(). Look at the log (adb logcat) and event log (adb logcat -b events) to see what the system is saying about launching and handling activities. Please don't use singleTask or singleInstance to fix such problems, they are not needed and have other repercussions you probably don't want. On Tue, Apr 20, 2010 at 7:07 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, thank you for your help! But I tried to add android:launchMode=singleTask or android:launchMode=singleInstance in the activity before, but it seems not work. The app still running twice or more at the same time by rotate screen or press return button, and launch the app. On Apr 21, 4:38 am, ~ TreKing treking...@gmail.com wrote: On Tue, Apr 20, 2010 at 2:06 AM, Kenneth WON kenneth...@gmail.com wrote: But my expected result is just have one and only one app A launch. http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... http://developer.android.com/intl/fr/guide/topics/manifest/activity-e.. . --- -- TreKing - Chicago transit tracking app for Android-powered deviceshttp:// sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2bunsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en
[android-developers] Re: How to solve the problem of launch the apps twice or more?
I also face the same problem, what I did was in manifest, inside activity, just included android:launchMode=singleTop and its working fine. What singleTop will do is, The standard and singleTop modes differ from each other in just one respect: Every time there's new intent for a standard activity, a new instance of the class is created to respond to that intent. Each instance handles a single intent. Similarly, a new instance of a singleTop activity may also be created to handle a new intent. However, if the target task already has an existing instance of the activity at the top of its stack, that instance will receive the new intent (in an onNewIntent() call); a new instance is not created. http://developer.android.com/guide/topics/manifest/activity-element.html#lmode Nithin On Apr 21, 9:05 am, Kenneth WON kenneth...@gmail.com wrote: Hi, Dianne Hackborn, Thank you! In the main activity, I will start a service, so I am calling startService() in onCreate(). Is that not necessary? On Apr 21, 11:25 am, Dianne Hackborn hack...@android.com wrote: Make sure you aren't calling startActivity() anywhere, such as in onCreate(). Look at the log (adb logcat) and event log (adb logcat -b events) to see what the system is saying about launching and handling activities. Please don't use singleTask or singleInstance to fix such problems, they are not needed and have other repercussions you probably don't want. On Tue, Apr 20, 2010 at 7:07 PM, Kenneth WON kenneth...@gmail.com wrote: Hi, thank you for your help! But I tried to add android:launchMode=singleTask or android:launchMode=singleInstance in the activity before, but it seems not work. The app still running twice or more at the same time by rotate screen or press return button, and launch the app. On Apr 21, 4:38 am, ~ TreKing treking...@gmail.com wrote: On Tue, Apr 20, 2010 at 2:06 AM, Kenneth WON kenneth...@gmail.com wrote: But my expected result is just have one and only one app A launch. http://developer.android.com/intl/fr/guide/topics/manifest/activity-e... http://developer.android.com/intl/fr/guide/topics/manifest/activity-e.. . --- -- TreKing - Chicago transit tracking app for Android-powered deviceshttp:// sites.google.com/site/rezmobileapps/treking -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group athttp:// groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.comandroid-developers%2Bunsubs cr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -- Dianne Hackborn Android framework engineer hack...@android.com Note: please don't send private questions to me, as I don't have time to provide private support, and so won't reply to such e-mails. All such questions should be posted on public forums, where I and others can see and answer them. -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group athttp://groups.google.com/group/android-developers?hl=en -- You received this message because you are subscribed to the Google Groups Android Developers group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en