[android-developers] Re: Saving service killing without startForeground
Hi everyone, I know it has been stated again and again that we should not start a service and leave it running for ever. What I was trying to do was to start a service once my package was installed, accomplish a couple of items and then stop the service (till my activity is started by the user). Is it achievable? I have added BOOT_COMPLETED in my manifest file hence when ever the device boots up I will start my service (and stop once I have completed a few items). The only scenario I am not able to cover is to start my service once the package is installed. How can I start my service in that instance? I tried catching the PACKAGE_INSTALL, PACKAGE_ADDED and PACKAGE_CHANGED but I dont think these are broadcasted to the newly installed packages. One alternative would be to force a reboot (programmatic) of the device (which i dont know how do either)? Any help will be appreciated Nick On Nov 23, 11:11 pm, Ash ashutoshkagra...@gmail.com wrote: At last I could find and fix the problem. The problem was after installing my package through ADT plug-in from Eclipse, for testingBOOT_COMPLETEDevent I had to restart the emulator every time, and when I run it again from Eclipse, my package receives theBOOT_COMPLETEDevent and starts running, but in between the Eclipse(ADT) tries to install the package again, which terminates my service/process. After installation when I run the emulator from outside the Eclipse, it works great. It was a silly problem to be discussed and happened because of my novelty in using Eclipse with ADT. The good thing is that I learned a lot of new concepts and APIs in the process of fixing this problem. Thanks Everyone!! Ash On Nov 23, 7:19 pm, Ash ashutoshkagra...@gmail.com wrote: Hi!! First of all I am extremely sorry for not providing the logs. (Kindly the find the logs below) Let me provide some more information about the service. Initially my test environment was full build, when I could successfully test the functionality I switched to SDK. The same software without a single line change works successfully without process killing/service crashing etc. I tried starting the service in a new thread as suggested but that didn’t help. Also my service is not getting restarted. I could not observe/find any Low Memory, ANR or Service crashing traces, though one of the trace says “Scheduling restart of crashed service com.mycompany.voip/.service.VoIPManager in 5000ms” Surprisingly, my service did not get killed and was alive life-long after I removed one of the permission “ACCESS_CHECKIN_PROPERTIES” from AndroidManifest.xml but that is not the real fix because with this fix I could not run it successfully next time. I am now clueless about the crash. Kindly provide some directions. Thanks in advance Ash Package Name: com.mycompany.voip Logcat –b event: --- I/boot_progress_start( 553): 4455 I/boot_progress_preload_start( 553): 5701 I/dvm_gc_info( 553): [8825198673194435749,-9065622874527238670,-4134462757533256206,0] I/dvm_gc_info( 553): [8825198673194411075,-9144998817959537112,-4131929482742753752,0] I/dvm_gc_info( 553): [8825198673194419250,-9164702066329053645,-4128833257998707149,0] I/dvm_gc_info( 553): [8825198673194427506,-9093207422244374979,-4126018508231428547,0] I/dvm_gc_info( 553): [8825198673194489386,-9016083278087436653,-4101811659696093549,0] I/dvm_gc_info( 553): [8825198673194550882,-8922632417303152977,-4093929191831849297,0] I/dvm_gc_info( 553): [8825198673194567275,-8923474642673121594,-4087453067807340858,0] I/dvm_gc_info( 553): [8825198673194583664,-8922909493427964195,-4080976944051259683,0] I/dvm_gc_info( 553): [8825198673194612348,-8919249218950650139,-4078724044457498907,0] I/dvm_gc_info( 553): [8825198673194612342,-8922625818891073797,-4072530495189760261,0] I/dvm_gc_info( 553): [8825198673194575421,-8974698689314085113,-4069152795200772345,0] I/dvm_gc_info( 553): [8825198673194542225,-9125005227097495779,-4062959245933058275,0] I/dvm_gc_info( 553): [8825198673194583229,-9065332530692524189,-4043255996220999837,0] I/dvm_gc_info( 553): [8825198673194591378,-9132886525103077527,-4041567146360731799,0] I/dvm_gc_info( 553): [8825198673194583156,-9088976428736206993,-4039878296500459665,0] I/dvm_gc_info( 553): [8825198673194595430,-9099109527109257353,-4037626495898241161,0] I/dvm_gc_info( 553): [8825198673194587298,-9080812554111428739,-4035936546526341251,0] I/dvm_gc_info( 553): [8825198673194603672,-9069553555026221182,-4026084922324686974,0] I/dvm_gc_info( 553): [8825198673194595416,-9126973350763554931,-4025802347836336243,0] I/dvm_gc_info( 553): [8825198673194615881,-9128099250653595752,-4025802347819534440,0] I/dvm_gc_info( 553):
[android-developers] Re: Saving service killing without startForeground
Hi all, I had a similar issue. What I wanted to do was to run a short service on boot up and initialize a few items and then stop the service. I understand that its not a good idea to leave the service running for the entire life-cycle of the phone. I was able to achieve this by creating a broadcast receiver and starting my service (and do some post delay items). I still need to figure out how to stop the service part. Please chime in if any one has any comments on this. I also wanted to start the same service once the package was installed. I tried using the PACKAGE_ADDED, PACKAGE_CHANGED intents but I guess the newly installed package does not receive these intents. Can any one point to another strategy for starting up my service after my package installation? An alternative would be to force phone re-boot after the package is installed (obviously after giving the choice to the user if he wants to continue or not) but I don't know how to force that either. Any ideas how to achieve that? Thanks for the help in advance Nick On Nov 23, 11:11 pm, Ash ashutoshkagra...@gmail.com wrote: At last I could find and fix the problem. The problem was after installing my package through ADT plug-in from Eclipse, for testing BOOT_COMPLETED event I had to restart the emulator every time, and when I run it again from Eclipse, my package receives the BOOT_COMPLETED event and starts running, but in between the Eclipse(ADT) tries to install the package again, which terminates my service/process. After installation when I run the emulator from outside the Eclipse, it works great. It was a silly problem to be discussed and happened because of my novelty in using Eclipse with ADT. The good thing is that I learned a lot of new concepts and APIs in the process of fixing this problem. Thanks Everyone!! Ash On Nov 23, 7:19 pm, Ash ashutoshkagra...@gmail.com wrote: Hi!! First of all I am extremely sorry for not providing the logs. (Kindly the find the logs below) Let me provide some more information about the service. Initially my test environment was full build, when I could successfully test the functionality I switched to SDK. The same software without a single line change works successfully without process killing/service crashing etc. I tried starting the service in a new thread as suggested but that didn’t help. Also my service is not getting restarted. I could not observe/find any Low Memory, ANR or Service crashing traces, though one of the trace says “Scheduling restart of crashed service com.mycompany.voip/.service.VoIPManager in 5000ms” Surprisingly, my service did not get killed and was alive life-long after I removed one of the permission “ACCESS_CHECKIN_PROPERTIES” from AndroidManifest.xml but that is not the real fix because with this fix I could not run it successfully next time. I am now clueless about the crash. Kindly provide some directions. Thanks in advance Ash Package Name: com.mycompany.voip Logcat –b event: --- I/boot_progress_start( 553): 4455 I/boot_progress_preload_start( 553): 5701 I/dvm_gc_info( 553): [8825198673194435749,-9065622874527238670,-4134462757533256206,0] I/dvm_gc_info( 553): [8825198673194411075,-9144998817959537112,-4131929482742753752,0] I/dvm_gc_info( 553): [8825198673194419250,-9164702066329053645,-4128833257998707149,0] I/dvm_gc_info( 553): [8825198673194427506,-9093207422244374979,-4126018508231428547,0] I/dvm_gc_info( 553): [8825198673194489386,-9016083278087436653,-4101811659696093549,0] I/dvm_gc_info( 553): [8825198673194550882,-8922632417303152977,-4093929191831849297,0] I/dvm_gc_info( 553): [8825198673194567275,-8923474642673121594,-4087453067807340858,0] I/dvm_gc_info( 553): [8825198673194583664,-8922909493427964195,-4080976944051259683,0] I/dvm_gc_info( 553): [8825198673194612348,-8919249218950650139,-4078724044457498907,0] I/dvm_gc_info( 553): [8825198673194612342,-8922625818891073797,-4072530495189760261,0] I/dvm_gc_info( 553): [8825198673194575421,-8974698689314085113,-4069152795200772345,0] I/dvm_gc_info( 553): [8825198673194542225,-9125005227097495779,-4062959245933058275,0] I/dvm_gc_info( 553): [8825198673194583229,-9065332530692524189,-4043255996220999837,0] I/dvm_gc_info( 553): [8825198673194591378,-9132886525103077527,-4041567146360731799,0] I/dvm_gc_info( 553): [8825198673194583156,-9088976428736206993,-4039878296500459665,0] I/dvm_gc_info( 553): [8825198673194595430,-9099109527109257353,-4037626495898241161,0] I/dvm_gc_info( 553): [8825198673194587298,-9080812554111428739,-4035936546526341251,0] I/dvm_gc_info( 553): [8825198673194603672,-9069553555026221182,-4026084922324686974,0] I/dvm_gc_info( 553): [8825198673194595416,-9126973350763554931,-4025802347836336243,0] I/dvm_gc_info( 553):
[android-developers] Re: Saving service killing without startForeground
Hi all, I had a similar issue. What I wanted to do was to run a short service on boot up and initialize a few items and then stop the service. I understand that its not a good idea to leave the service running for the entire life-cycle of the phone. I was able to achieve this by creating a broadcast receiver and starting my service (and do some post delay items). I still need to figure out how to stop the service part. Please chime in if any one has any comments on this. I also wanted to start the same service once the package was installed. I tried using the PACKAGE_ADDED, PACKAGE_CHANGED intents but I guess the newly installed package does not receive these intents. Can any one point to another strategy for starting up my service after my package installation? An alternative would be to force phone re-boot after the package is installed (obviously after giving the choice to the user if he wants to continue or not) but I dont know how to force that either. Any ideas how to achieve that? Thanks for the help in advance Nick On Nov 23, 11:11 pm, Ash ashutoshkagra...@gmail.com wrote: At last I could find and fix the problem. The problem was after installing my package through ADT plug-in from Eclipse, for testing BOOT_COMPLETED event I had to restart the emulator every time, and when I run it again from Eclipse, my package receives the BOOT_COMPLETED event and starts running, but in between the Eclipse(ADT) tries to install the package again, which terminates my service/process. After installation when I run the emulator from outside the Eclipse, it works great. It was a silly problem to be discussed and happened because of my novelty in using Eclipse with ADT. The good thing is that I learned a lot of new concepts and APIs in the process of fixing this problem. Thanks Everyone!! Ash On Nov 23, 7:19 pm, Ash ashutoshkagra...@gmail.com wrote: Hi!! First of all I am extremely sorry for not providing the logs. (Kindly the find the logs below) Let me provide some more information about the service. Initially my test environment was full build, when I could successfully test the functionality I switched to SDK. The same software without a single line change works successfully without process killing/service crashing etc. I tried starting the service in a new thread as suggested but that didn’t help. Also my service is not getting restarted. I could not observe/find any Low Memory, ANR or Service crashing traces, though one of the trace says “Scheduling restart of crashed service com.mycompany.voip/.service.VoIPManager in 5000ms” Surprisingly, my service did not get killed and was alive life-long after I removed one of the permission “ACCESS_CHECKIN_PROPERTIES” from AndroidManifest.xml but that is not the real fix because with this fix I could not run it successfully next time. I am now clueless about the crash. Kindly provide some directions. Thanks in advance Ash Package Name: com.mycompany.voip Logcat –b event: --- I/boot_progress_start( 553): 4455 I/boot_progress_preload_start( 553): 5701 I/dvm_gc_info( 553): [8825198673194435749,-9065622874527238670,-4134462757533256206,0] I/dvm_gc_info( 553): [8825198673194411075,-9144998817959537112,-4131929482742753752,0] I/dvm_gc_info( 553): [8825198673194419250,-9164702066329053645,-4128833257998707149,0] I/dvm_gc_info( 553): [8825198673194427506,-9093207422244374979,-4126018508231428547,0] I/dvm_gc_info( 553): [8825198673194489386,-9016083278087436653,-4101811659696093549,0] I/dvm_gc_info( 553): [8825198673194550882,-8922632417303152977,-4093929191831849297,0] I/dvm_gc_info( 553): [8825198673194567275,-8923474642673121594,-4087453067807340858,0] I/dvm_gc_info( 553): [8825198673194583664,-8922909493427964195,-4080976944051259683,0] I/dvm_gc_info( 553): [8825198673194612348,-8919249218950650139,-4078724044457498907,0] I/dvm_gc_info( 553): [8825198673194612342,-8922625818891073797,-4072530495189760261,0] I/dvm_gc_info( 553): [8825198673194575421,-8974698689314085113,-4069152795200772345,0] I/dvm_gc_info( 553): [8825198673194542225,-9125005227097495779,-4062959245933058275,0] I/dvm_gc_info( 553): [8825198673194583229,-9065332530692524189,-4043255996220999837,0] I/dvm_gc_info( 553): [8825198673194591378,-9132886525103077527,-4041567146360731799,0] I/dvm_gc_info( 553): [8825198673194583156,-9088976428736206993,-4039878296500459665,0] I/dvm_gc_info( 553): [8825198673194595430,-9099109527109257353,-4037626495898241161,0] I/dvm_gc_info( 553): [8825198673194587298,-9080812554111428739,-4035936546526341251,0] I/dvm_gc_info( 553): [8825198673194603672,-9069553555026221182,-4026084922324686974,0] I/dvm_gc_info( 553): [8825198673194595416,-9126973350763554931,-4025802347836336243,0] I/dvm_gc_info( 553):
Re: [android-developers] Re: Saving service killing without startForeground
I had a similar issue. What I wanted to do was to run a short service on boot up and initialize a few items and then stop the service. I understand that its not a good idea to leave the service running for the entire life-cycle of the phone. I was able to achieve this by creating a broadcast receiver and starting my service (and do some post delay items). I still need to figure out how to stop the service part. Please chime in if any one has any comments on this. I do not know what you mean by how to stop the service part. If a service wants to stop itself, it can call stopSelf(). Can any one point to another strategy for starting up my service after my package installation? Let the user start it by launching your activity. An alternative would be to force phone re-boot after the package is installed (obviously after giving the choice to the user if he wants to continue or not) but I dont know how to force that either. Any ideas how to achieve that? You can't reboot the phone programmatically, unless you are part of the firmware, AFAIK. -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html -- 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: Saving service killing without startForeground
Thanks Mark Ok so for the first issue (stopping service) I will try your suggestion. For second question, when my activity starts there is an involved process of initializing bunch of items which requires few seconds. Hence I wanted to initialize these via a service on BOOT_COMPLETE (working for me already) or on the package installation (which I am trying to figure out). This way when the activity is started by the user there wont be any wait. ~Nick On Fri, Dec 4, 2009 at 12:50 PM, Mark Murphy mmur...@commonsware.comwrote: I had a similar issue. What I wanted to do was to run a short service on boot up and initialize a few items and then stop the service. I understand that its not a good idea to leave the service running for the entire life-cycle of the phone. I was able to achieve this by creating a broadcast receiver and starting my service (and do some post delay items). I still need to figure out how to stop the service part. Please chime in if any one has any comments on this. I do not know what you mean by how to stop the service part. If a service wants to stop itself, it can call stopSelf(). Can any one point to another strategy for starting up my service after my package installation? Let the user start it by launching your activity. An alternative would be to force phone re-boot after the package is installed (obviously after giving the choice to the user if he wants to continue or not) but I dont know how to force that either. Any ideas how to achieve that? You can't reboot the phone programmatically, unless you are part of the firmware, AFAIK. -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html -- 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 -- 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: Saving service killing without startForeground
I will try your suggestion. For second question, when my activity starts there is an involved process of initializing bunch of items which requires few seconds. Hence I wanted to initialize these via a service on BOOT_COMPLETE (working for me already) or on the package installation (which I am trying to figure out). This way when the activity is started by the user there wont be any wait. Just show a ProgressDialog, ProgressBar, title bar progress indicator, animated ImageView, or something, and do the initialization in the activity. Or, find ways to initialize the items progressively, such that you can start some the main functionality after a fraction of the initialization time. Or, spend more time optimizing the initialization process. To put it another way: if you find a way to auto-start your application without user involvement for the first run, that will probably be considered a security hole. Android goes out of its way to make sure that users run the app the first time, even if after that the app can arrange for scheduled tasks and the like. I am similarly concerned by your BOOT_COMPLETED strategy. Adding seconds of time to the boot process is bad for Android, even if you think it may be good for your app. Bear in mind that BOOT_COMPLETED is a slight misnomer, and there is a bunch of other stuff going on then (e.g., home screen launching, radios turning on), that your initialization logic will be impeding. -- Mark Murphy (a Commons Guy) http://commonsware.com Android App Developer Books: http://commonsware.com/books.html -- 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: Saving service killing without startForeground
On Fri, Dec 4, 2009 at 9:45 AM, Nick ladn...@gmail.com wrote: I also wanted to start the same service once the package was installed. I tried using the PACKAGE_ADDED, PACKAGE_CHANGED intents but I guess the newly installed package does not receive these intents. Can any one point to another strategy for starting up my service after my package installation? No, you deliberately must wait for the user to launch your app. An alternative would be to force phone re-boot after the package is installed (obviously after giving the choice to the user if he wants to continue or not) but I dont know how to force that either. Good ghod, no. Reason #78 why there should be no API for -that-. :p -- 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
Re: [android-developers] Re: Saving service killing without startForeground
Thanks Mark and Dianne for your inputs. I will keep that in mind. ~Nick On Fri, Dec 4, 2009 at 2:12 PM, Dianne Hackborn hack...@android.com wrote: On Fri, Dec 4, 2009 at 9:45 AM, Nick ladn...@gmail.com wrote: I also wanted to start the same service once the package was installed. I tried using the PACKAGE_ADDED, PACKAGE_CHANGED intents but I guess the newly installed package does not receive these intents. Can any one point to another strategy for starting up my service after my package installation? No, you deliberately must wait for the user to launch your app. An alternative would be to force phone re-boot after the package is installed (obviously after giving the choice to the user if he wants to continue or not) but I dont know how to force that either. Good ghod, no. Reason #78 why there should be no API for -that-. :p -- 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 at http://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
[android-developers] Re: Saving service killing without startForeground
Hi!! First of all I am extremely sorry for not providing the logs. (Kindly the find the logs below) Let me provide some more information about the service. Initially my test environment was full build, when I could successfully test the functionality I switched to SDK. The same software without a single line change works successfully without process killing/service crashing etc. I tried starting the service in a new thread as suggested but that didn’t help. Also my service is not getting restarted. I could not observe/find any Low Memory, ANR or Service crashing traces, though one of the trace says “Scheduling restart of crashed service com.mycompany.voip/.service.VoIPManager in 5000ms” Surprisingly, my service did not get killed and was alive life-long after I removed one of the permission “ACCESS_CHECKIN_PROPERTIES” from AndroidManifest.xml but that is not the real fix because with this fix I could not run it successfully next time. I am now clueless about the crash. Kindly provide some directions. Thanks in advance Ash Package Name: com.mycompany.voip Logcat –b event: --- I/boot_progress_start( 553): 4455 I/boot_progress_preload_start( 553): 5701 I/dvm_gc_info( 553): [8825198673194435749,-9065622874527238670,-4134462757533256206,0] I/dvm_gc_info( 553): [8825198673194411075,-9144998817959537112,-4131929482742753752,0] I/dvm_gc_info( 553): [8825198673194419250,-9164702066329053645,-4128833257998707149,0] I/dvm_gc_info( 553): [8825198673194427506,-9093207422244374979,-4126018508231428547,0] I/dvm_gc_info( 553): [8825198673194489386,-9016083278087436653,-4101811659696093549,0] I/dvm_gc_info( 553): [8825198673194550882,-8922632417303152977,-4093929191831849297,0] I/dvm_gc_info( 553): [8825198673194567275,-8923474642673121594,-4087453067807340858,0] I/dvm_gc_info( 553): [8825198673194583664,-8922909493427964195,-4080976944051259683,0] I/dvm_gc_info( 553): [8825198673194612348,-8919249218950650139,-4078724044457498907,0] I/dvm_gc_info( 553): [8825198673194612342,-8922625818891073797,-4072530495189760261,0] I/dvm_gc_info( 553): [8825198673194575421,-8974698689314085113,-4069152795200772345,0] I/dvm_gc_info( 553): [8825198673194542225,-9125005227097495779,-4062959245933058275,0] I/dvm_gc_info( 553): [8825198673194583229,-9065332530692524189,-4043255996220999837,0] I/dvm_gc_info( 553): [8825198673194591378,-9132886525103077527,-4041567146360731799,0] I/dvm_gc_info( 553): [8825198673194583156,-9088976428736206993,-4039878296500459665,0] I/dvm_gc_info( 553): [8825198673194595430,-9099109527109257353,-4037626495898241161,0] I/dvm_gc_info( 553): [8825198673194587298,-9080812554111428739,-4035936546526341251,0] I/dvm_gc_info( 553): [8825198673194603672,-9069553555026221182,-4026084922324686974,0] I/dvm_gc_info( 553): [8825198673194595416,-9126973350763554931,-4025802347836336243,0] I/dvm_gc_info( 553): [8825198673194615881,-9128099250653595752,-4025802347819534440,0] I/dvm_gc_info( 553): [8825198673194611838,-9068143981102590050,-4025519773331187810,0] I/dvm_gc_info( 553): [8825198673194735225,-8919235953104992345,-4025512008013527129,0] I/dvm_gc_info( 553): [8825198673194976883,-8922613584089225282,-4024948989323810882,0] I/dvm_gc_info( 553): [8825198673194714700,-8953575762791110703,-4024667445610813487,0] I/dvm_gc_info( 553): [8825198673194648745,-9065884278481877031,-4024385970617317415,0] I/dvm_gc_info( 553): [8825198673194660987,-9068699028248975393,-4024385970617309217,0] I/dvm_gc_info( 553): [8825198673194652775,-9106979625064843289,-4024385970600527897,0] I/dvm_gc_info( 553): [8825198673194665038,-9135127122350028817,-4017630570773592081,0] I/dvm_gc_info( 553): [8825198673194652716,-9208029141318088724,-4017630570773592084,0] I/dvm_gc_info( 553): [8825198673194939451,-9128371722875402249,-4015660245903046665,6825561] I/dvm_gc_info( 553): [8825198673194660910,-9144415796547901442,-4014815820972906498,6825600] I/boot_progress_preload_end( 553): 17087 I/dvm_gc_info( 553): [8825198673194689569,-9190296217751738369,-4014534345996195841,7370389] I/dvm_gc_info( 553): [8825198673194660859,-9165526419801204739,-4014534345996199939,7370389] I/dvm_gc_info( 553): [8825198673194676824,-9213095690865305603,-4014534345996199939,7370389] I/boot_progress_system_run( 587): 17917 I/boot_progress_pms_start( 587): 18289 I/boot_progress_pms_system_scan_start( 587): 18784 I/dvm_gc_info( 587): [8320808730292176444,-8974404086165411804,-4017630296264763395,7370389] I/dvm_gc_info( 587): [8320808730292123191,-9014936139130365911,-4016222921381210117,7370389] I/boot_progress_pms_data_scan_start( 587): 20686 I/boot_progress_pms_scan_end( 587): 20731 I/boot_progress_pms_ready( 587): 20858 I/dvm_gc_info( 587): [8320808730292078120,-9028165394316310487,-4016222921381210117,7370389] I/battery_status( 587): [2,2,1,1,Li-ion] I/battery_level( 587): [50,0,0] I/power_screen_state( 587):
[android-developers] Re: Saving service killing without startForeground
At last I could find and fix the problem. The problem was after installing my package through ADT plug-in from Eclipse, for testing BOOT_COMPLETED event I had to restart the emulator every time, and when I run it again from Eclipse, my package receives the BOOT_COMPLETED event and starts running, but in between the Eclipse(ADT) tries to install the package again, which terminates my service/process. After installation when I run the emulator from outside the Eclipse, it works great. It was a silly problem to be discussed and happened because of my novelty in using Eclipse with ADT. The good thing is that I learned a lot of new concepts and APIs in the process of fixing this problem. Thanks Everyone!! Ash On Nov 23, 7:19 pm, Ash ashutoshkagra...@gmail.com wrote: Hi!! First of all I am extremely sorry for not providing the logs. (Kindly the find the logs below) Let me provide some more information about the service. Initially my test environment was full build, when I could successfully test the functionality I switched to SDK. The same software without a single line change works successfully without process killing/service crashing etc. I tried starting the service in a new thread as suggested but that didn’t help. Also my service is not getting restarted. I could not observe/find any Low Memory, ANR or Service crashing traces, though one of the trace says “Scheduling restart of crashed service com.mycompany.voip/.service.VoIPManager in 5000ms” Surprisingly, my service did not get killed and was alive life-long after I removed one of the permission “ACCESS_CHECKIN_PROPERTIES” from AndroidManifest.xml but that is not the real fix because with this fix I could not run it successfully next time. I am now clueless about the crash. Kindly provide some directions. Thanks in advance Ash Package Name: com.mycompany.voip Logcat –b event: --- I/boot_progress_start( 553): 4455 I/boot_progress_preload_start( 553): 5701 I/dvm_gc_info( 553): [8825198673194435749,-9065622874527238670,-4134462757533256206,0] I/dvm_gc_info( 553): [8825198673194411075,-9144998817959537112,-4131929482742753752,0] I/dvm_gc_info( 553): [8825198673194419250,-9164702066329053645,-4128833257998707149,0] I/dvm_gc_info( 553): [8825198673194427506,-9093207422244374979,-4126018508231428547,0] I/dvm_gc_info( 553): [8825198673194489386,-9016083278087436653,-4101811659696093549,0] I/dvm_gc_info( 553): [8825198673194550882,-8922632417303152977,-4093929191831849297,0] I/dvm_gc_info( 553): [8825198673194567275,-8923474642673121594,-4087453067807340858,0] I/dvm_gc_info( 553): [8825198673194583664,-8922909493427964195,-4080976944051259683,0] I/dvm_gc_info( 553): [8825198673194612348,-8919249218950650139,-4078724044457498907,0] I/dvm_gc_info( 553): [8825198673194612342,-8922625818891073797,-4072530495189760261,0] I/dvm_gc_info( 553): [8825198673194575421,-8974698689314085113,-4069152795200772345,0] I/dvm_gc_info( 553): [8825198673194542225,-9125005227097495779,-4062959245933058275,0] I/dvm_gc_info( 553): [8825198673194583229,-9065332530692524189,-4043255996220999837,0] I/dvm_gc_info( 553): [8825198673194591378,-9132886525103077527,-4041567146360731799,0] I/dvm_gc_info( 553): [8825198673194583156,-9088976428736206993,-4039878296500459665,0] I/dvm_gc_info( 553): [8825198673194595430,-9099109527109257353,-4037626495898241161,0] I/dvm_gc_info( 553): [8825198673194587298,-9080812554111428739,-4035936546526341251,0] I/dvm_gc_info( 553): [8825198673194603672,-9069553555026221182,-4026084922324686974,0] I/dvm_gc_info( 553): [8825198673194595416,-9126973350763554931,-4025802347836336243,0] I/dvm_gc_info( 553): [8825198673194615881,-9128099250653595752,-4025802347819534440,0] I/dvm_gc_info( 553): [8825198673194611838,-9068143981102590050,-4025519773331187810,0] I/dvm_gc_info( 553): [8825198673194735225,-8919235953104992345,-4025512008013527129,0] I/dvm_gc_info( 553): [8825198673194976883,-8922613584089225282,-4024948989323810882,0] I/dvm_gc_info( 553): [8825198673194714700,-8953575762791110703,-4024667445610813487,0] I/dvm_gc_info( 553): [8825198673194648745,-9065884278481877031,-4024385970617317415,0] I/dvm_gc_info( 553): [8825198673194660987,-9068699028248975393,-4024385970617309217,0] I/dvm_gc_info( 553): [8825198673194652775,-9106979625064843289,-4024385970600527897,0] I/dvm_gc_info( 553): [8825198673194665038,-9135127122350028817,-4017630570773592081,0] I/dvm_gc_info( 553): [8825198673194652716,-9208029141318088724,-4017630570773592084,0] I/dvm_gc_info( 553): [8825198673194939451,-9128371722875402249,-4015660245903046665,6825561] I/dvm_gc_info( 553): [8825198673194660910,-9144415796547901442,-4014815820972906498,6825600] I/boot_progress_preload_end( 553): 17087 I/dvm_gc_info( 553):
[android-developers] Re: Saving service killing without startForeground
Thanks for responding!! Well!! I am working with emulator currently and the behaviour is same. I have confirmed from the logs that the service is not crashing. All I could observe from the logs that System is killing the service(and hence the process) as its not a system service. your service is not using a background thread Well my service is a multi-threaded application but not sure what you mean here. Its a Android application/process with only one service and nothing more than it.Do you mean I should start a thread for running the service? I thought of utilizing the process as its only one service in the process. Thanks in advance Ash On Nov 20, 1:52 pm, Ash ashutoshkagra...@gmail.com wrote: Hi!!, I am running a background Android Service as VoIP Framework which provides different VoIP services to different Android applications, (VoIP call, Video Call, etc). The service establishes a network connection with the Server(Service Provider) and does some initial handshake before it can start providing service to the Android applications, that’s why though of starting the service on BOOT_COMPLETED event. The problem is when the service gets started on BOOT_COMPLETED event, before even it finishes the initial network connection with server and handshaking, it gets killed by the system. I have tried using setForeground which improves the behavior a bit but still gets killed mid-way. I am working with old version 1.5 r3 of SDK and hence, cannot use startForeground. Is there a way out or another alternative available with SDK 1.5 r3? Thanks in advance, Ash -- 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: Saving service killing without startForeground
Ash wrote: your service is not using a background thread Well my service is a multi-threaded application but not sure what you mean here. Your service presumably implements some combination of onCreate(), onStart(), onBind(), and onDestroy(). It might also implement some other callbacks, objects on which Android will invoke certain methods at certain times. All of those will be called on the main application thread -- in an activity, we'd call this the UI thread. You should not be doing anything that takes much time on the UI thread. If you take too much time, Android will assume your service is stuck and will kill it off with the service equivalent of an Application Not Responding (ANR) error. -- Mark Murphy (a Commons Guy) http://commonsware.com | http://twitter.com/commonsguy Android Consulting/App Development: http://commonsware.com/consulting -- 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: Saving service killing without startForeground
2009/11/20 Cédric Berger cedric.berge...@gmail.com But if your service process is killed due to low memory, won't the system try to restart it later ? (though of course if there are still too many services running there is still a problem) Yes if the service was started with startService(), the system will continue trying to restart it (using a back-off timeout to avoid thrashing too much) until there is enough memory to run it again. If there are just too many services trying to run at the same time, you will end up cycling through the services running each of them some of the time. The only reason the service in this case would just be stopped and not started again is if it has crashed a couple times, or has ANRed in the background (in which case a dialog is not shown, but the system detects this and kills the process). Also note -- if you are using setForeground() it is EXTREMELY unlikely the system is killing your service due to low memory, since this API basically turns that off. (Though note in 2.0 this API no longer does anything, and you need to use the new APIs that tie this state to a notification; for older releases, you are supposed to do this so the user can know what is going on and stop the service, and this is now enforced in 2.0.) If you find your service going away while it is in the foreground, you should be looking for the service crashing or ANRing rather than thinking the system is killing it for memory. And I'll say again please please please avoid just running services continually in the background. We don't have enough memory in a lot of the devices for more than a few applications to do this. If you really need to, please make it clear in your app that this is happening, with a UI for the user to stop the service if they don't need it. And you will just have to deal with the fact that there will be situations where the system can't keep your service running -- for example, if the user goes to a fairly heavy-weight web site, this itself could consume enough memory that the system needs to kill most if not all of the background services for that time. Finally, you can find some information about what the system is doing in the log with adb logcat. There is often some more useful details in the low-level event log that you can see with adb logcat -b events. If you are going to ask for help with these kinds of questions, it would be extremely useful to post the log output that is seen when the service process goes away. Also you can use adb shell dumpsys activity.services to see the state of all services. If your service has been started, even if its process is killed and it is not running, you will see it in here, with a number of useful things about its current state. -- 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: Saving service killing without startForeground
If you're running on a G1, and have even low-mid memory reqs, you are pretty much SOL. Android will kill off processes to free resources for new foreground activities, and services, particularly those running in a background process, will get axed first. Watch logcat in verbose mode to validate that this is indeed what is happening. Things are going to get even worse for you in 1.6. Donut itself consumes more memory leaving less room for your background service. Once a foreground activity is bound to your service, the service will be much less likely to get killed, so your only option in low-mem scenarios may be to check at binding time and see if your persistent connection is available, and reconnect if not. This approach is the best solution that I can think of for gracefully degrading the functionality of your service in low-mem situations. On Nov 20, 3:52 am, Ash ashutoshkagra...@gmail.com wrote: Hi!!, I am running a background Android Service as VoIP Framework which provides different VoIP services to different Android applications, (VoIP call, Video Call, etc). The service establishes a network connection with the Server(Service Provider) and does some initial handshake before it can start providing service to the Android applications, that’s why though of starting the service on BOOT_COMPLETED event. The problem is when the service gets started on BOOT_COMPLETED event, before even it finishes the initial network connection with server and handshaking, it gets killed by the system. I have tried using setForeground which improves the behavior a bit but still gets killed mid-way. I am working with old version 1.5 r3 of SDK and hence, cannot use startForeground. Is there a way out or another alternative available with SDK 1.5 r3? Thanks in advance, Ash -- 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: Saving service killing without startForeground
On Fri, Nov 20, 2009 at 14:53, dadical keyes...@gmail.com wrote: If you're running on a G1, and have even low-mid memory reqs, you are pretty much SOL. Android will kill off processes to free resources for new foreground activities, and services, particularly those running in a background process, will get axed first. Watch logcat in verbose mode to validate that this is indeed what is happening. Things are going to get even worse for you in 1.6. Donut itself consumes more memory leaving less room for your background service. Once a foreground activity is bound to your service, the service will be much less likely to get killed, so your only option in low-mem scenarios may be to check at binding time and see if your persistent connection is available, and reconnect if not. This approach is the best solution that I can think of for gracefully degrading the functionality of your service in low-mem situations. Indeed on my magic, logcat often shows that background processes were killed while booting due too low memory, even before I could do anything. (yes I am trying to reduce as much unuseful apps as possible... what is bad is theses apps I do not need to autostart though I do not want to uninstall). But if your service process is killed due to low memory, won't the system try to restart it later ? (though of course if there are still too many services running there is still a problem) And anyway, your could at boot time just set an alarm to defer the initialisation of your service. So that a lot of processes that where running at boot time will have finished and more resources are available. You may also still try to do your job immediatly, but before that set an alarm in case of. (But in case of low memory this will just slow down the phone at startup, for nothing.) -- 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