我的警报服务不会开火

时间:2015-05-05 13:04:54

标签: android notifications

我到处搜索但我能理解,因为我在一天的特定时间的服务不会解雇。什么都没发生。 我的代码用于设置闹钟:

AlarmManager alarmMgr = (AlarmManager) act.getSystemService(Context.ALARM_SERVICE);
        Intent intent = new Intent(act, AlarmReceiver.class);
        PendingIntent alarmIntent = PendingIntent.getBroadcast(act, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT);
        // set for 5 seconds later
        alarmMgr.set(AlarmManager.RTC_WAKEUP, Calendar.getInstance().getTimeInMillis()+5000, alarmIntent);

我的服务代码:

public class AlarmReceiver extends BroadcastReceiver {

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

        System.out.println("Alarm worked well");
        Utils.criarNotificacao(context);
    }
}

在清单中:

<receiver android:name="br.com.blacktoad.q48h2.utils.AlarmReceiver" android:process=":remote"></receiver>

我找不到任何答案。

1 个答案:

答案 0 :(得分:0)

我发现了错误! 我需要把:

<receiver android:name="br.com.blacktoad.q48h2.utils.AlarmReceiver" android:process=":remote"></receiver>
清单中的

,但包含在“应用程序”标记中