- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我无法修复在 Eclipse 中遇到的此错误。这是一个引进的项目。除了这个错误之外,其他一切都正常:
The method setLatestEventInfo(Context, String, String, PendingIntent) is undefined for the type Notification MyNotificationBuilderToGingerBread.java /CANAPP/src/com/ftech/canapp/notification line 14 Java Problem
这是我正在处理的代码
package com.ftech.canapp.notification;
import android.app.Notification;
import android.app.PendingIntent;
import android.content.Context;
public class MyNotificationBuilderToGingerBread {
Notification notification = null;
@SuppressWarnings("deprecation")
public MyNotificationBuilderToGingerBread(Context myContext, int icon, String ticker, String title, String info, Long timeStamp, PendingIntent pendingIntent) {
notification = new Notification(icon, ticker, timeStamp);
notification.setLatestEventInfo(myContext, title, info, pendingIntent);
}
@SuppressWarnings("deprecation")
public MyNotificationBuilderToGingerBread(Context myContext, int icon, String ticker, String title, String info, Long timeStamp, PendingIntent pendingIntent, int flags) {
notification = new Notification(icon, ticker, timeStamp);
notification.setLatestEventInfo(myContext, title, info, pendingIntent);
}
public Notification get() {
return notification;
}
}
最佳答案
我已在所有版本中使用此包装器:
public static Notification notification(Context ctx, String title, int icon,
long when, PendingIntent pIntent, String contentTitle,
String contentText,int flags, int defaults){
NotificationCompat.Builder builder = new NotificationCompat.Builder(ctx);
Notification notification = builder.setContentIntent(pIntent)
.setSmallIcon(icon).setTicker(title).setWhen(when).setContentTitle(contentTitle)
.setContentText(contentText).setDefaults(defaults).build();
notification.flags = flags;
return notification;
}
关于java - 如何修复方法 setLatestEventInfo(Context, String, String, PendingIntent) 未定义类型通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33857636/
我制作了提醒应用程序,但无法解析方法 setLatestEventInfo 方法。 public class NotifyService extends Service { public cl
我知道“setLatestEventInfo”已被弃用。但我必须使用它来兼容 api lv 8 设备,因为新的通知调用功能与 api 8 设备不兼容。 我在某些项目中使用了“setLatestEven
这个问题已经有答案了: Cannot Resolve Method setLatestEventInfo (4 个回答) 已关闭 7 年前。 我正在尝试为我的应用程序实现提醒功能(API 23)。 但
我正在尝试在 api 级别 10 和以下是我的代码,但我收到语法错误 setLatestEventInfo 无法解决。我猜它与 API 级别有关 public static void sendNot
我正在处理通知,我必须使用 setLatestEventInfo。但是,Android Studio 显示以下错误消息: cannot resolve method setLatestEventinf
您好,我在这一点上有库存,其中“setLatesEventInfo”有错误。我知道 setLatestEventInfo 不会在 API 23 及更高版本上运行。有人可以帮助我如何运行这段代码吗?我的
我最近开发了一个应用程序,但是Android studio不再支持setLatestEventInfo方法,因此,我尝试将此方法更改为Notification.Builder方法。但是,我很挣扎,因此
我正在更新我的应用,使其与 Android 6.0 中的新权限模型保持一致。更新了我的 build.gradle 文件后,我现在收到了停止构建的编译消息: Warning:com.google.and
我正在创建一个模拟推送通知应用程序。它从用户那里获取输入并在设备上显示本地推送通知。据我所知,setLatestEventInfo 方法在新的 API (23+) 级别中已停用。我想知道代码的可能补丁
我在 Android Studio 中工作并尝试在特定日期和时间生成通知。一切正常,但是,在我的服务类 setLatestEventInfo() 方法中无法解析。我在 eclipse 中做过同样的演示
Feel free to improve the title I'm a little uncreative in this special case. 我正在实现一个单元测试来检查通知,我知道这几乎
Notification notification = new Notification(R.drawable.stat_sample, getText
我无法修复在 Eclipse 中遇到的此错误。这是一个引进的项目。除了这个错误之外,其他一切都正常: The method setLatestEventInfo(Context, String, St
我正在尝试在我的应用程序中实现推送通知,但它在“setLatestEventInfo”上给出错误。我做错了什么? 这是我的代码GcmMessageHandler.java: public class
我无法使用 API 26 更新应用。当我尝试运行项目时出现以下错误 错误: "ServerRunningNotification.java": error: cannot find symbol me
我是一名优秀的程序员,十分优秀!