在一个广播接收器上注册的多个动作在android中不起作用

时间:2017-06-06 07:27:18

标签: android broadcastreceiver reboot

我在一个接收器下注册了多个意图

 <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

<receiver
        android:name="com.test.callerpopup.CallerPopUp"
        android:enabled="true"
        android:exported="true">

 <intent-filter >
            <action android:name="android.intent.action.REBOOT" ></action>
            <action android:name="android.intent.action.BOOT_COMPLETED" ></action>
            <action android:name="android.intent.action.PHONE_STATE" ></action>
        </intent-filter>

在我的广播接收器类

@Override
public void onReceive(final Context context, Intent intent) {

    String phone_state = intent.getStringExtra(TelephonyManager.EXTRA_STATE);


    if (phone_state.equals(TelephonyManager.EXTRA_STATE_RINGING) ){
 Toast.makeText(context, "Incoming Call", Toast.LENGTH_LONG).show();

}

应用程序的正常执行工作正常,但是当我重新启动手机时,吐司无效。为什么?我在&#34; REBOOT&#34;上注册了接收器。和&#34; BOOT_COMPLETED&#34;

0 个答案:

没有答案