This is my short description about my widget and main application. Sorry because of my English (English is not my mother tongue)
I have a music player widget. When this widget enabled, I need bind to a music player service (A) of main application. Because we cannot bind a service in AppWidgetProvider so I start a local service (B) in AppWidgetProvider and bind to that music player service (A) from here. Furthermore, I also have a service C to do widget’s button function.
Everything seems to be working fine but when my main app with service A all forced stop (they will be restating a moment later) I must rebind to A from widget. Problem is when main app was forced stop, I cannot rebind to A because context(I stored Context as a global variable in AppWidgetProvider whenever I receive context from onEnabled, onUpdate) is NULL.
My question is how about my above widget structure? Should service B stoped when bind to A done? How can i bind to service A again when main app and service a was forced stop (but they will automatically restart a moment later).
Thanks you!
Answer my own question
context.getApplicationContext().bindService(..)MyMainApplication.Instance().getApplicationContext().bindService(..)