[英]Android broadcast receiver && App running status
我在应用程序中使用了第三方推送服务,当从服务器推送消息时,它的后台服务将发送广播,我必须收听,此过程运行良好。 在onReceive()函数中,我可以显示通知,也可以静默地做一些工作。 是否显示通知取决于应用程序状态,即:
if(application_is_running){
if(message_type == chat_message){
if(chat_activity_is_present){
/** notification not allowed **/
}else{
/** show notification, open the corresponding chat activity on clicking the notification */
}
}else{
/** store the message silently **/
}
}else{
/** show notification, and start the app on clicking the notification**/
}
当广播接收器从服务器获取推送消息时,通知我的应用程序的最佳实践是什么?
- 编辑 -
通过最佳实践,我的意思是将消息发送(而不更改应用程序中的消息处理逻辑)到应用程序进行处理的最佳方法。
这可能会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.