Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android-替换不推荐的通知类_Android_Android Notifications - Fatal编程技术网

Android-替换不推荐的通知类

Android-替换不推荐的通知类,android,android-notifications,Android,Android Notifications,我想知道我可以用什么来替换不推荐使用的通知类和setLatestEventInfo()方法。它无法识别setLatestEventInfo()方法 以下是我的当前代码: public void makeForeground() { Notification notification = new Notification(R.drawable.icon, getText(R.string.servicename), System.currentTimeMillis()); notifica

我想知道我可以用什么来替换
不推荐使用的通知类
setLatestEventInfo()
方法。它无法识别
setLatestEventInfo()
方法

以下是我的当前代码:

public void makeForeground() {
  Notification notification = new Notification(R.drawable.icon, getText(R.string.servicename), System.currentTimeMillis());
  notification.setLatestEventInfo(this, getText(R.string.servicename), this.lang[134], PendingIntent.getActivity(this, 0, new Intent(this, UIActivity.class), 0));
  startForeground(2, notification);
}

我可以用什么替换它?

您可以使用NotificationCompat替换通知

您可以在此处阅读更多内容:


  • 你能给我一个启动前台服务的例子吗。他们仍在文档站点上使用SetLateStevenInfo。