当数据库更改 Android 时收到通知 [英] Get notified when database change Android
问题描述
我有一个 SQL Server 数据库,当表中有插入时,我想通知 Android 应用程序.
I have a SQL Server database and when there is insert in a table I want to notify the Android app.
例如,当收到订单时,我将其插入到 SQL Server 数据库中.我还希望用户在我的应用中收到有关订单的通知.该应用程序始终处于打开状态.我使用网络服务与数据库联系.
For example, when order receives, I insert it into a SQL Server database. I also want user to get notification in my app about the order. The app is always open. I use web services to contact with database.
我不想每 10 秒左右请求一次桌子.还有其他办法吗?
I don't want to request the table every 10 seconds or so. Is there any other way?
推荐答案
可以使用谷歌云消息服务,看如何设置服务器此处.
You can use Google Cloud messaging service, see how to set server here.
示例:如果您使用 PHP,那么在插入或更改任何数据时,您可以推送通知 GCM 到给定的潜水.或者你可以在SQL中设置触发器并调用系统服务来通知GCM.
Example: if you are using PHP then while inserting or changing any data you can push to notify GCM to the given dives. or else you can set triggers in SQL and call system services to notify GCM.
这篇关于当数据库更改 Android 时收到通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!