0

当我的手机收到短信时,它会将其上传到我的数据库。在平板电脑上,我应该尽快收到有关新消息的通知。

如何有效地检查数据库中的新消息?我认为每隔几秒钟查询一次数据库的后台进程根本就没有效率。它会耗尽电池,并且是网络的巨大浪费。

4

1 回答 1

1

Have a static BroadcastReceiver in your App as a listener. If a text message comes in the receiver will get started and onReceive() will get called. Now you can invoke a Service/ an Activity to save it to your database and put up a notification.

Here's a nice tutorial to get you started.

于 2013-10-06T13:36:59.573 回答