BroadcastReceiver不接收TIME_SET,DATE_CHANGED动作

时间:2015-08-05 08:39:02

标签: android broadcastreceiver

我尝试捕捉日期和时间的变化。为此,我注册了

<receiver android:enabled="true" android:name=".model.ChangeTimeReceiver">
            <intent-filter>
                <action android:name="ANDROID.INTENT.ACTION.DATE_CHANGED"/>
                <action android:name="ANDROID.INTENT.ACTION.TIME_SET"/>
            </intent-filter>

但是系统

不调用方法onRecive()

我的收件人代码

public class ChangeTimeReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("ChangeTimeReceiver", "onReceive")
    }
} 

1 个答案:

答案 0 :(得分:3)

操作标识符区分大小写,请尝试以下操作:

<receiver android:enabled="true" android:name=".model.ChangeTimeReceiver">
    <intent-filter>
        <action android:name="android.intent.action.DATE_CHANGED"/>
        <action android:name="android.intent.action.TIME_SET"/>
    </intent-filter>