【问题标题】:android icon on status bar状态栏上的安卓图标
【发布时间】:2014-07-15 13:56:09
【问题描述】:

我可以设置即使关机再开机后手机图标仍然存在? 比如闹钟

我使用这个代码:

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

  }

关闭手机后,图标消失,但应用可以正常工作

【问题讨论】:

    标签: android notifications statusbar


    【解决方案1】:

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

    Trying to start a service on boot on Android

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多