0

我的应用程序的广播接收器有问题。

我有一种情况,我希望广播接收器因 3 个不同的原因而被调用,第一个电话状态发生了变化,第二个是基于计时器,第三个是启动完成。然后根据调用广播接收器的原因,我希望能够做一些事情。

下面是我的接收器的 android 清单:

    <receiver android:name="com.example.mobileraptor.MyPhoneListener" >
        <intent-filter>
            <action android:name="android.intent.action.PHONE_STATE" />
            <action android:name="android.intent.action.BOOT_COMPLETED" />

            <action android:name="com.example.mobileraptor.TimerTriggered" />

        </intent-filter>
    </receiver>

以下是我声明我的 TimerTriggered 意图的地方:

PendingIntent pintent = PendingIntent.getBroadcast( this, 0, new Intent("com.example.mobileraptor.TimerTriggered"), 0 );
    AlarmManager manager = (AlarmManager)(this.getSystemService( Context.ALARM_SERVICE ));

    manager.setInexactRepeating( AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), AlarmManager.INTERVAL_HOUR , pintent );

问题是一旦应用程序想要启动它就会崩溃。但如果我评论这一行:action android:name="com.example.mobileraptor.TimerTriggered
那么我的应用程序很好。

我定义的动作名称有什么问题。

4

0 回答 0