Good afternoon friends. I am new to programming and at the moment I am ripping a simple reminder application. The essence of the problem: at a given time, reminders just do not work. No mistake, nothing. The debugging message in the body of the notification creation method also does not appear, i.e. as I understand the process in this unit does not even reach. Thank you for your responses.

Activity code that creates the notification

public class ReminderService extends WakeReminderIntentService { public ReminderService() { super("ReminderService"); } @Override void doReminderWork(Intent intent) { Long rowId = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID); NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Intent notificationIntent = new Intent(this, RemindersEdit.class); notificationIntent.putExtra(RemindersDbAdapter.KEY_ROWID, rowId); PendingIntent pi = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_ONE_SHOT); NotificationCompat.Builder builder = new NotificationCompat.Builder(this); Notification notification = builder .setContentIntent(pi) .setSmallIcon(R.drawable.note_icon) .setTicker(getString(R.string.notify_new_task_message)) .setWhen(System.currentTimeMillis()) .setAutoCancel(true).setContentTitle(getString(R.string.notify_new_task_title)) .setContentText(getString(R.string.notify_new_task_message)) .build(); Log.d ("Note","Note has to be done" ); int id = (int) ((long) rowId); mgr.notify(id, notification); } } 

It inherits this class (responsible for blocking processor off)

 public abstract class WakeReminderIntentService extends IntentService { abstract void doReminderWork(Intent intent); public static final String LOCK_NAME_STATIC = "com.dummies.android.taskreminder.Static"; private static PowerManager.WakeLock lockStatic=null; public static void acquireStaticLock(Context context) { getLock(context).acquire(); } synchronized private static PowerManager.WakeLock getLock(Context context) { if (lockStatic==null) { PowerManager mgr = (PowerManager) context.getSystemService(Context.POWER_SERVICE); lockStatic = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOCK_NAME_STATIC); lockStatic.setReferenceCounted(true); } return(lockStatic); } public WakeReminderIntentService(String name) { super(name); } @Override final protected void onHandleIntent(Intent intent) { try { doReminderWork(intent); } finally { getLock(this).release(); } } } 

And probably another reminder setup class should be shown.

 public class ReminderManager{ private Context mContext; private AlarmManager mAlarmManager; public ReminderManager(Context context) { mContext = context; mAlarmManager = (AlarmManager)context.getSystemService(Context.ALARM_SERVICE); } public void setReminder(Long taskId, Calendar when) { Log.d("SetReminder", "Started"); Intent i = new Intent(mContext, OnAlarmReceiver.class); i.putExtra(RemindersDbAdapter.KEY_ROWID, (long) taskId); PendingIntent pi = PendingIntent.getBroadcast (mContext, 0, i, PendingIntent.FLAG_ONE_SHOT); mAlarmManager.set(AlarmManager.RTC_WAKEUP, when.getTimeInMillis(), pi); } } 

UPDATE The OnAlarmReciever code into which the intent from the ReminderManager is thrown.

 import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log; public class OnAlarmReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { long rowid = intent.getExtras().getLong(RemindersDbAdapter.KEY_ROWID); WakeReminderIntentService.acquireStaticLock(context); Intent i = new Intent(context,ReminderService.class); i.putExtra(RemindersDbAdapter.KEY_ROWID, rowid); context.startService(i); Log.d ("OnAlarmReciever", "onRecieveDone"); } } 
  • Add the class code of OnAlarmReceiver , into which the Intent from RemindManager is thrown - EgorD
  • Thanks, added! - Barbashov Bogdan

0