У меня проблема с уведомлением в строке состояния с интервалом в 10 секунд. Я сделал с кодом для отображения его один раз, создав плагин. Но я хочу отображать его каждые 10 минут. Так что я использовал AlarmManager
для генерации уведомления каждые 10 минут. Но он не вызывает onReceive(Context ctx, Intent intent)
метод FirstQuoteAlarm
класс. У меня есть следующий код для отображения уведомлений и AlarmManager
.уведомление о статусе в телефоне телефона Android
public void showNotification(CharSequence contentTitle, CharSequence contentText) {
int icon = R.drawable.nofication;
long when = System.currentTimeMillis();
Notification notification = new Notification(icon, contentTitle, when);
Intent notificationIntent = new Intent(ctx, ctx.getClass());
PendingIntent contentIntent = PendingIntent.getActivity(ctx, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(1, notification);
Date dt = new Date();
Date newdate = new Date(dt.getYear(), dt.getMonth(), dt.getDate(),10,14,dt.getSeconds());
long triggerAtTime = newdate.getTime();
long repeat_alarm_every = 1000;
QuotesSetting.ON = 1;
AlarmManager am = (AlarmManager) ctx.getSystemService(Context.ALARM_SERVICE);
//Intent intent = new Intent("REFRESH_ALARM");
Intent intent1 = new Intent(ctx,FirstQuoteAlarm.class);
PendingIntent pi = PendingIntent.getBroadcast(ctx, 0, intent1, 0);
am.setRepeating(AlarmManager.RTC_WAKEUP, triggerAtTime, repeat_alarm_every, pi);
Log.i("call2","msg");
}
Почему бы вам обновлять каждые 10 минут? это довольно недружелюбно – Dediqated