状态栏上的android图标

时间:2014-05-26 18:49:56

标签: android notifications statusbar

我可以设置即使关闭后打开手机图标仍然停留? 例如,闹钟

我使用此代码:

  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();

  }

关闭手机后,图标消失但应用程序正常运行

1 个答案:

答案 0 :(得分:2)

本质上,通知不会在设备重启时持续存在。您将手动确定设备何时重新启动并再次发出通知。

Trying to start a service on boot on Android