Android: How to trigger screen UI events (e.g incoming call screen) by a long running background service?

StackOverflow https://stackoverflow.com/questions/20629433

  •  18-09-2022
  •  | 
  •  

Question

I'm quite new to android. I'm building an application that uses the android smack library to communicate with my XMPP server. I am able to send and receive messages perfectly however what I want is to run this ENTIRE sending and receiving messages code to a long term running process in the background and on receiving a certain message I want to launch a screen (something similar to the incoming call screen of android) no matter what the user is doing on his smartphone i.e. when the activity running the messaging service is not open (in a similar way when you get an incoming call from a viber contact and you get faced with the screen even though you obviously dont have the viber application open). Any ideas on how exactly to do this ? I have a few ideas in mind after research but dont quite seem to get the correct way and glue all peaces together.

Thanks in advance

Was it helpful?

Solution

you can use intentService to communicate with mainThread

here is a basic examples of intentservice and service

http://mobile.tutsplus.com/tutorials/android/android-fundamentals-intentservice-basics/

service example

http://www.vogella.com/articles/AndroidServices/article.html

here is an official document

http://developer.android.com/reference/android/app/IntentService.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top