简体   繁体   中英

Check database and receive android notification

I have a database with datas and my android application when it was launched checks if there is a new record in the database. I created a Service and it checks every ten seconds if there is a new record and alert me with a notification. I think it isn't the best solution cause it checks every ten seconds so it use the battery and internet every ten seconds. Is there another solution to do that without check every ten seconds, for example, by using some code in my php form which add content in my database. Thanks in advance.

You are right, there is plenty of solutions.

One of powerfull solutions is implementation of publish subscribe pattern. In short: All subscribed clients will be notified on any change for which they are subscribed.

For quick info and start point use this link: https://developers.google.com/cloud/samples/mbs/pubsub_messaging .

General about publish subscribe: http://docs.oracle.com/cd/E19798-01/821-1841/bnced/index.html

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