应用之前未运行时是否可以启动Android服务并广播 [英] Is it possible starting Android Service and Broadcast when app did not run before

查看:123
本文介绍了应用之前未运行时是否可以启动Android服务并广播的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的应用运行一次,则服务可以启动并在后台请求服务器。但是当应用程序之前未运行时,服务将无法启动。

If my app runs once, service can start and request to server on background. But when app did not run before, service could not start. Is it possible starting service even that app have not runned before.

实际上我想做的是,手机可以一次将请求发送到服务器,而无需运行。发送请求后,它将被激活。不需要以后的请求。

Actually what I want to do is that phone can send request to server for once without even runned before. When request sended, it will be activation. Later request is not to require.

推荐答案

不,这是不可能的。

当您用户首次 OR 强行关闭该应用程序,该应用程序处于非活动状态(这意味着没有广播接收器或警报将起作用),并且仅在用户使用时才处于活动状态

When your app is getting installed for the first time OR was force-closed by the user, it is in "inactive" state (meaning no broadcast receivers or alarms will work), and will become active only when the user launches it manually.

查看详细信息此处

这篇关于应用之前未运行时是否可以启动Android服务并广播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆