How to show notification from background service?

前端 未结 2 1993
野趣味
野趣味 2020-12-30 09:31

The project I am working on has two different apps, 1 is server and other is client. Server app has 1 service class, which initiates server thread in onStartCommand()<

2条回答
  •  醉话见心
    2020-12-30 10:17

    Am I reading this incorrectly? Both your server app and your client app are both on the same Android device?

    In any case, take a look at the ApiDemos for code for notifications through a service.

    And since you're probably going to be dealing with a remote server (and not a local one) and all the latency issues associated with the network, I think you better wrap your service in an AsyncTask.

    Also learn about Broadcast Receivers, registered Broadcast Receivers can be great way to trigger Services/Activities without the need to have your own Service polling in a loop indefinitely.

提交回复
热议问题