Android : start activity from background service
I have a background service running all the time after bootup. Based on some condition I have to start activity from service and get the response from activity. Af开发者_Go百科ter getting the response I have to do some processing in service.
I google searched and found that I should use notifications. But its not clear how to send the response back from activity to service.
Can anyone please help me out.
Thnaks.
The reason for notifications is that the background service shouldn't just suddenly pop up with some UI demanding input. I'd suggest you use status bar notifications to signal that you need some input. The user can then opt in to activate the notification which in turn issues the intent to display the activity. The activity in turn can use service binding mechanisms to communicate any data back to the service.
In other words: the background service remain as passive as possible and the user is still in charge.
精彩评论