无需申请即可启动服务
我有一个呼叫阻止应用程序。它有 3 个文件:
- class BlockMyCall extends BroadcastReceiver
- class SimpleClass1 extends Service
- PhoneBlock extends Activity
我启动“PhoneBlock”活动来调用服务“SimpleClass1”,最终调用“BlockMyCall”来阻止出站呼叫(通过将结果设置为“null”)。
我想知道我是否可以在不启动活动的情况下从服务运行 class1 。如果是这样,怎么办?
I have a call blocking application. It has 3 files:
- class BlockMyCall extends BroadcastReceiver
- class SimpleClass1 extends Service
- PhoneBlock extends Activity
I start "PhoneBlock " Activity to call Service "SimpleClass1", which eventually calls "BlockMyCall" intended to block outbound calls (by setting result to "null").
I want to know if I can run the class1 from service without starting activity. If so, how?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将广播接收器设置为 READ_PHONE_STATE 并在接收到此广播后启动服务。
Put a broadcast receiver to READ_PHONE_STATE and on receiving this broadcast ,start the service.
在您的 AndroidManifest 中,您可以指定接收器在启动时启动,如下所示:
我不能 100% 确定这就是您想要实现的目标。
In your AndroidManifest you can specify the receiver to start at boot like this:
I'm not 100% sure that is what your looking to achieve or not.