android service check for new messages while app is running
I have an app that users can get messages but there is no way they no they have a message unless the app is currently open. They dont even no if they have a message if the app is in recent activity. What i want to do is when the user logs in it starts like开发者_如何学JAVA a service or timer or something of that nature so it goes through a loop and keep checking the database for a message. Any suggestions please post code example, i am lost when it comes to stuff like this. Thanks!
Use BroadCast Receiver and register it in Manifest.xml so that it will listen to your message(broadcast) when app is not running also http://developer.android.com/guide/topics/manifest/receiver-element.html
精彩评论