0

I can set even after turning off and turn on the phone icon still stays? For example, an alarm clock

i use this code:

  public void setNotificationToStatusBar(){
      String forwarder_start_str= getResources().getString(R.string.sms_forwarding_activated);
      String app_name=getResources().getString(R.string.app_name);
      Intent intent= new Intent(this, PrefActivitySmsForwarder.class);
      Notification n= new Notification(R.drawable.ic_launcher,forwarder_start_str, System.currentTimeMillis());
      n.flags=Notification.FLAG_ONGOING_EVENT;
      PendingIntent pi=PendingIntent.getActivity(getApplicationContext(), 0,intent,0);
      n.setLatestEventInfo(getApplicationContext(), app_name, forwarder_start_str, pi);
      n.defaults= Notification.DEFAULT_ALL;
      nm.notify(uniqueId, n);
      finish();

  }

After I turn off the phone, the icon disappears but the app works

allpnay
  • 539
  • 6
  • 19

1 Answers1

2

By nature, notifications will not persist through a device reboot. You will manually need to determine when the device has been restarted and issue the notification again.

Trying to start a service on boot on Android

Community
  • 1
  • 1
cjbrooks12
  • 1,368
  • 1
  • 13
  • 25