从开始一个BroadcastReceiver应用(NEW_OUTGOING_CALL并不总是有效) [英] Starting the application from a BroadCastReceiver (NEW_OUTGOING_CALL doesn't always work)

查看:1645
本文介绍了从开始一个BroadcastReceiver应用(NEW_OUTGOING_CALL并不总是有效)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我已经写了通过拨打特定号码启动应用程序,我已经使用的 NEW_OUTGOING_CALL (一撒施接收器),以赶上拨号事件。
到目前为止,在我的Andr​​oidManifest.xml中的广泛铸接收器就像下面code:

Well, I've written an application that starts by dialing an specific number, I have used NEW_OUTGOING_CALL(a broad cast receiver) to catch the dial event. So far the broad cast receiver on my AndroidManifest.xml is like the following code:

<receiver android:name=".CustomBroadCastReceiver">
    <intent-filter>
         <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
    </intent-filter>
</receiver>

问题是,当我尝试一个新的系统上,它不会在第一次工作,但几次测试之后,它开始工作。
我检查了Android的日志,并认为它甚至不注册为广播接收器。
我找不到这种行为在Android中引用的理由,想知道是否有人有同样的问题,并找到解决方案了,

The problem is that when I try it on a new system, it doesn't work at first , But after a few times testing, it starts working. I have checked the android logs and think it doesn't even register as a broadcast receiver. I couldn't find a reason for this behavior in Android reference, And want to know if anybody had the same problem and found solution for it,

请考虑这一广泛的投接收机假设是我的应用程序的起始触发

Please consider that this broad cast receiver is suppose to be the starting trigger of my application

我也看到一些关于停止包,我想知道这是否是有关我的情况,如果是,是否有一种方法来设置标志,如在AndroidManifest.xml中

I have also read something about stopped packages, And I want to know if it is related to my case, And if it is, is there a way to set flags such as FLAG_INCLUDE_STOPPED_PACKAGES on AndroidManifest.xml

====== ======编辑

在我调用下面的命令首次在亚行外壳

After I call the following command for the first time on adb shell

am broadcast -n com.package.name/.StartApp

出现在仿真器的日志此行

This line appears on the Emulator's log

06-15 11:17:53.216: INFO/ActivityManager(74): Start proc com.package.name for broadcast com.package.name/.StartApp: pid=2153 uid=10041 gids={3003}

和再撒施接收机结婚登记在模拟器上,看起来像我的应用程序需要以注册撒施接收器启动

And then the broad cast receiver get registered on the Emulator, Looks like my application needs to be started in order to register the broad cast receiver

推荐答案

我无法找到Android的文档中任何东西,但是花几个小时在不同的设备上测试这种情况后,我发现广播接收机只的注册执行程序后。因此很明显,一个活动必须在安装后启动,然后一切都完美。

I couldn't found anything in android documentation, But after spending hours testing this case on different devices, I found out that broadcast receivers only register after the application is executed. So apparently one activity must be started after installation and then everything works perfectly.

这篇关于从开始一个BroadcastReceiver应用(NEW_OUTGOING_CALL并不总是有效)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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