- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我最近开发了一个应用程序,但是Android studio不再支持setLatestEventInfo
方法,因此,我尝试将此方法更改为Notification.Builder
方法。但是,我很挣扎,因此我希望有人支持我将此方法更改为 Notification.Builder
方法。
String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "Fall Detector";
long when = System.currentTimeMillis();
notification = new Notification(icon, tickerText, when);
mContext = getApplicationContext();
CharSequence contentTitle = "Fall Detector";
CharSequence contentText = "Running";
Intent notificationIntent = new Intent(this,StartActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
notification.setLatestEventInfo(mContext, contentTitle, contentText,
contentIntent);
mNotificationManager.notify(1, notification);
我已经尝试了以下方法,但是,它说它无法解析符号内容 Intent 。
String ns = Context.NOTIFICATION_SERVICE;
int icon = R.drawable.ic_launcher;
CharSequence tickerText = "Fall Detector";
long when = System.currentTimeMillis();
notification = new Notification(icon, tickerText, when);
mNotificationManager = (NotificationManager) getSystemService(ns);
Notification.Builder builder = new Notification.Builder(mContext)
.setContentTitle("Fall Detector")
.setContentText("Running")
.setContentIntent(contentIntent);
builder.build();
Notification notification = builder.getNotification();
mNotificationManager.notify(1, notification);
最佳答案
I have tried the below, however, it says that it cannot resolve symbol contentintent.
这是因为您未能将原始代码中的某些行复制到修改后的代码中:
Intent notificationIntent = new Intent(this,StartActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
notificationIntent, 0);
在开始配置 Notification.Builder
之前,将这些内容添加到修订后的代码中。
关于java - 无法解析 setLatestEventInfo 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45042492/
我制作了提醒应用程序,但无法解析方法 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
我是一名优秀的程序员,十分优秀!