Java 无法解析符号(contentIntent)
几年前我创建了一个应用程序,但是,我刚刚更新了Android Studio,因此,我的通知代码不起作用,因为Android在最新的SDK版本中没有使用此功能。我尝试在我的代码中使用Java 无法解析符号(contentIntent),java,android,android-notifications,Java,Android,Android Notifications,几年前我创建了一个应用程序,但是,我刚刚更新了Android Studio,因此,我的通知代码不起作用,因为Android在最新的SDK版本中没有使用此功能。我尝试在我的代码中使用notification.Builder,但是,我收到了一个错误,请有人帮助我 我收到的错误是无法解析符号(contentIntent) 这应该起作用: Notification.Builder builder = new Notification.Builder(mContext); builder.setSmall
notification.Builder
,但是,我收到了一个错误,请有人帮助我
我收到的错误是无法解析符号(contentIntent)代码>
这应该起作用:
Notification.Builder builder = new Notification.Builder(mContext);
builder.setSmallIcon(R.drawable.ic_launcher)
builder.setContentTitle("Fall Detector")
builder.setContentText("Running")
builder.setContentIntent(contentIntent);
builder.build();
Notification notification = builder.getNotification();
mNotificationManager.notify(1, notification);
你的contentIntent变量在哪里?请屏幕截图苏菲的可能复制品请在我挣扎的时候为我重写我的方法。谢谢您尝试通知时收到的错误。生成器?(您写了“一些错误”)它无法识别contentIntent和.Build。它无法同时解析这两个文件,因为它无法解析(contentIntent),所以该文件不起作用@user8162255确保contentIntent实例是Greaper,或者我已经重写了代码检查我的问题,但是,它仍然说无法解决(contentIntent)@用户8162255你能为你的错误截图吗?或者共享源代码的更多部分?因为如果你想让你的pendingent像这样pendingent pendingent=pendingent.getActivity(this,requestCode,intent,0),它应该可以工作代码>
Notification.Builder builder = new Notification.Builder(mContext);
builder.setSmallIcon(R.drawable.ic_launcher)
builder.setContentTitle("Fall Detector")
builder.setContentText("Running")
builder.setContentIntent(contentIntent);
builder.build();
Notification notification = builder.getNotification();
mNotificationManager.notify(1, notification);