2

毎月8日に通知を設定したいです。

これは私がしたことです:

Intent myIntent = new Intent(remember.this, receiver.class);
        PendingIntent pendingIntent = PendingIntent.getBroadcast(remember.this, 0, myIntent, 0);

        AlarmManager alarmManager = (AlarmManager)getSystemService(ALARM_SERVICE);


        // Set the alarm to start at approximately 8th of 
        Calendar calendar = Calendar.getInstance();
        calendar.setTimeInMillis(System.currentTimeMillis());
        calendar.set(Calendar.DAY_OF_MONTH, 8);


        alarmManager.setInexactRepeating(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
                AlarmManager.INTERVAL_DAY*30, pendingIntent);

しかし、私が受け取ったのは、数分以内の一定の通知でした。そして、これは消えません。

どこが間違っていたのか本当にわからないので、ここで助けていただければ幸いです。

4

1 に答える 1

-1

カレンダーを次の月の 8 日に設定します。

alarmManager.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis() , pendingIntent);

receiver.class の内部

public void onReceive(Context context, Intent intent) {
//do action needed
//invoke alarmManager in mainActivity
// cancel the previous alarm 
// set the new alarm for the next month
}
于 2015-04-29T12:55:23.863 に答える