本文介绍了没有应用程序启动服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个呼叫阻塞应用程序。它有3个文件:

I have a call blocking application. It has 3 files:

  1. 类BlockMyCall扩展的BroadcastReceiver
  2. 类SimpleClass1扩展服务
  3. PhoneBlock延伸活动

我开始PhoneBlock活动来调用服务SimpleClass1,最终调用BlockMyCall意在阻止出站电话(通过设置结果为空)。

I start "PhoneBlock " Activity to call Service "SimpleClass1", which eventually calls "BlockMyCall" intended to block outbound calls (by setting result to "null").

我想知道如果我能运行服务Class1的,但不启动活动。如果是这样,怎么样?

I want to know if I can run the class1 from service without starting activity. If so, how?

推荐答案

将广播接收器READ_PHONE_STATE并在收到该广播,启动该服务。

Put a broadcast receiver to READ_PHONE_STATE and on receiving this broadcast ,start the service.

这篇关于没有应用程序启动服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 00:45