Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/230.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
Java 无法解析符号(contentIntent)_Java_Android_Android Notifications - Fatal编程技术网

Java 无法解析符号(contentIntent)

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

几年前我创建了一个应用程序,但是,我刚刚更新了Android Studio,因此,我的通知代码不起作用,因为Android在最新的SDK版本中没有使用此功能。我尝试在我的代码中使用
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);