[android-developers] Re: Binding with service lost after calling unbindService()
HI Once Again, I have tried to start the LocalService in APIDEMOS on bootup complete from a broadcast receiver then tried to run the Local service Binding example code(which calls bindService() unbindService() apis). As observed in my app(case 2 listed by me) here again after the first bindService() unbindService() api calls, the example could not communicate with the local service(so I dont expect this behavior to be caused by some code written by my app). Although I did manage to do a work around.The workaround is to call stopService() after the unbindService() is called. After this bindService() unbindService() seems to work without any problem. Pls advice whether this is a good way to handle this situation. Any suggestions for the workaround are welcome. Looking for to more responses on this discussion. Abraham On Jan 14, 10:17 am, Abraham abraham_thamarapal...@yahoo.co.in wrote: HI Al, I have tried putting the logs my observations are as follows: Case 1: when the local service not started up on boot up complete. From UI Call bindService() to start the service. Since the service is not yet started onCreate() is called followed by onBind() of the local service. From onServiceConnected() UI get the instance of service, register a callback handler(so that service can inform UI once the desired operation is complete) invoke the desire operation. Once the operation is completed the UI calls unbindService(). In this case the service is killed on unbindService(). Also as mentioned by me earlier in this case the binding / unbinding works multiple times each time ui is able to communicate with service. Case 2: LocalService is started on boot up complete. On Bootup complete event the service is started by calling startService (). This invokes onCreate() followed by onStart() of the local service. The service is started at this point. On user action UI now invokes bindservice() to bind the service with UI.From onServiceConnected() UI get the instance of service, register a callback handler(so that service can inform UI once the desired operation is complete) invoke the desire operation. Once the operation is completed the UI calls unbindService(). In this case the service is not killed since stopself() or stopservice() is not called. From this point on I cannot bind again with the service, i.e. bindService() returns true...but onBind() is never called. On Jan 14, 2:53 am, Al alcapw...@googlemail.com wrote: Binding and unbinding many times works fine for also. Try adding log messages to your service's onCreate, onStart, onBind methods to see if they are being called and investigate from there. On Tue, Jan 13, 2009 at 5:00 AM,Abraham abraham_thamarapal...@yahoo.co.inwrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance.- Hide quoted text - - Show quoted text -- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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: Binding with service lost after calling unbindService()
HI, Logs showing memory leak when unbindService is not called. 01-15 14:14:30.904: ERROR/ActivityThread(209): Activity com.android.mobilink.MobiLinkMenu has leaked ServiceConnection com.android.mobilink.mobilinkmen...@43390770 that was originally bound here 01-15 14:14:30.904: ERROR/ActivityThread(209): android.app.ServiceConnectionLeaked: Activity com.android.mobilink.MobiLinkMenu has leaked ServiceConnection com.android.mobilink.mobilinkmen...@43390770 that was originally bound here 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.app.ActivityThread$PackageInfo$ServiceDispatcher.init (ActivityThread.java:878) 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.app.ActivityThread$PackageInfo.getServiceDispatcher (ActivityThread.java:773) 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.app.ApplicationContext.bindService(ApplicationContext.java: 784) 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.content.ContextWrapper.bindService(ContextWrapper.java:307) 01-15 14:14:30.904: ERROR/ActivityThread(209): at com.android.mobilink.MobiLinkMenu.okPressed(MobiLinkMenu.java:220) 01-15 14:14:30.904: ERROR/ActivityThread(209): at com.android.mobilink.Utility$1.onClick(Utility.java:51) 01-15 14:14:30.904: ERROR/ActivityThread(209): at com.android.internal.app.AlertController$ButtonHandler.handleMessage (AlertController.java:148) 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.os.Handler.dispatchMessage(Handler.java:88) 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.os.Looper.loop(Looper.java:123) 01-15 14:14:30.904: ERROR/ActivityThread(209): at android.app.ActivityThread.main(ActivityThread.java:3742) 01-15 14:14:30.904: ERROR/ActivityThread(209): at java.lang.reflect.Method.invokeNative(Native Method) 01-15 14:14:30.904: ERROR/ActivityThread(209): at java.lang.reflect.Method.invoke(Method.java:515) 01-15 14:14:30.904: ERROR/ActivityThread(209): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:739) 01-15 14:14:30.904: ERROR/ActivityThread(209): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:497) 01-15 14:14:30.904: ERROR/ActivityThread(209): at dalvik.system.NativeStart.main(Native Method) On Jan 13, 7:14 pm, zero zeroo...@googlemail.com wrote: i have seen things like that, myself. could you, by any chance, provide us with the logs of the memory leak ? it might not even be necessary to call unbind(), because you can call the service's thru the obtained interface without being bound to it. (btw, the general problem class is still unfixed on my side as well) On Jan 13, 2:00 pm,Abrahamabraham_thamarapal...@yahoo.co.in wrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance.- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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: Binding with service lost after calling unbindService()
i have seen things like that, myself. could you, by any chance, provide us with the logs of the memory leak ? it might not even be necessary to call unbind(), because you can call the service's thru the obtained interface without being bound to it. (btw, the general problem class is still unfixed on my side as well) On Jan 13, 2:00 pm, Abraham abraham_thamarapal...@yahoo.co.in wrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance. --~--~-~--~~~---~--~~ 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: Binding with service lost after calling unbindService()
No problem connecting with the local service using unbindService and bindService. I have several Activities using this model without an issue. Are you testing on the emulator or the device ? If you are trying it on emulator, and the boot event happens before uninstall of the package(your app) occurs, then your service is killed. Best way to check would be to see if onCreate of the service is being called when you are binding. Also I have used: bindService(new Intent(myActivity.this, MyService.class), mConnection, Context.BIND_AUTO_CREATE); Thanks Chander On Jan 13, 6:00 pm, Abraham abraham_thamarapal...@yahoo.co.in wrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance. --~--~-~--~~~---~--~~ 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: Binding with service lost after calling unbindService()
Repeatedly binding and unbinding works fine in the local service sample (which you can test by pressing the buttons), so my first question would be what you are doing different than it. Likewise you can see that if you bind the service, then go to the other local service sample, you are still able to start the service there. On Tue, Jan 13, 2009 at 5:00 AM, Abraham abraham_thamarapal...@yahoo.co.inwrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance. -- 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. 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: Binding with service lost after calling unbindService()
Binding and unbinding many times works fine for also. Try adding log messages to your service's onCreate, onStart, onBind methods to see if they are being called and investigate from there. On Tue, Jan 13, 2009 at 5:00 AM, Abraham abraham_thamarapal...@yahoo.co.inwrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance. --~--~-~--~~~---~--~~ 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: Binding with service lost after calling unbindService()
HI Al, I have tried putting the logs my observations are as follows: Case 1: when the local service not started up on boot up complete. From UI Call bindService() to start the service. Since the service is not yet started onCreate() is called followed by onBind() of the local service. From onServiceConnected() UI get the instance of service, register a callback handler(so that service can inform UI once the desired operation is complete) invoke the desire operation. Once the operation is completed the UI calls unbindService(). In this case the service is killed on unbindService(). Also as mentioned by me earlier in this case the binding / unbinding works multiple times each time ui is able to communicate with service. Case 2: LocalService is started on boot up complete. On Bootup complete event the service is started by calling startService (). This invokes onCreate() followed by onStart() of the local service. The service is started at this point. On user action UI now invokes bindservice() to bind the service with UI.From onServiceConnected() UI get the instance of service, register a callback handler(so that service can inform UI once the desired operation is complete) invoke the desire operation. Once the operation is completed the UI calls unbindService(). In this case the service is not killed since stopself() or stopservice() is not called. From this point on I cannot bind again with the service, i.e. bindService() returns true...but onBind() is never called. On Jan 14, 2:53 am, Al alcapw...@googlemail.com wrote: Binding and unbinding many times works fine for also. Try adding log messages to your service's onCreate, onStart, onBind methods to see if they are being called and investigate from there. On Tue, Jan 13, 2009 at 5:00 AM,Abraham abraham_thamarapal...@yahoo.co.inwrote: HI All, I'm facing an issue with my application need your expert opinion in resolving the issue. My app has a local service which is started by calling startService() when the phone boot up is complete. My app also has a UI component which the user can use for making use of the service. Following the Local service binding example in ApiDemos my app is calling bindService () api to bind with the local service make use of the local service instance obtained through the IBinder in onServiceConnected() to perform operations provided by the service. Once the operation is completed my app calls unbindService() to disconnect the UI from the service. From this point on my app cannot communicate with the local service by calling bindService() or startService(). Has anyone faced similar issues. If yes, what is the work around. Am I doing something wrong. Another observation is that if I donot call unbindService() I'm able to make use of the operations provided by the service, although it leads to memory leaks ( as displayed in the logs) . Looking forward your response. Thanx in advance.- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---