无法解析符号(contentIntent)

时间:2017-07-11 14:54:35

标签: java android android-notifications

我几年前创建了一个应用程序,但是,我刚刚更新了Android工作室,因此,我的通知代码无效,因为Android在我尝试使用Notification.Builder的最新SDK版本中没有使用它但是,我的代码收到错误,所以有人可以帮助我。

我收到的错误是cannot Resolve symbol (contentIntent);

String ns = Context.NOTIFICATION_SERVICE;
mNotificationManager = (NotificationManager) getSystemService(ns);

Notification.Builder builder = new Notification.Builder(mContext)
    .setSmallIcon(R.drawable.ic_launcher)
    .setContentTitle("Fall Detector")
    .setContentText("Running")
    .setContentIntent(contentIntent);
builder.build();
Notification notification = builder.getNotification();

mNotificationManager.notify(1, notification);

2 个答案:

答案 0 :(得分: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);

答案 1 :(得分:0)

ur contentIntent变量在哪里?请截图