简体   繁体   中英

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. After 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM