ViewEventActivity.class 无法识别
ViewEventActivity.class is not recognised
我的代码源是https://developer.android.com/training/wearables/notifications/creating.html
在此示例代码中,第二部分 NotificationCompat 工作得很好..但我在 MainActivity.class 中有此代码,它给出了一个错误 "ViewEventActivity.class is not recognised"
现在这是什么ViewEventActivity.class,在哪里添加它以及如何实现它
代码片段::
int notificationId = 001;
// Build intent for notification content
Intent viewIntent = new Intent(this, ViewEventActivity.class);
viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
PendingIntent viewPendingIntent =
PendingIntent.getActivity(this, 0, viewIntent, 0);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_event)
.setContentTitle(eventTitle)
.setContentText(eventLocation)
.setContentIntent(viewPendingIntent);
// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());
任何建议都会有很大帮助
替换
Intent viewIntent = new Intent(this, ViewEventActivity.class);
与
Intent viewIntent = new Intent();
这就是在单击 Notification.Its 时启动 Activity 的示例代码,与 Android 无关 API.if 您希望在单击时启动任何 Activity然后用 ViewEventActivity.class
替换 Activity
否则忽略它
"ViewEventActivity.class is not recognized"
ViewEventActivity
与任何 API 的 class 无关。所以你需要创建你自己的class,你想在通知点击时用任何名字打开它,而不是像其他class一样ViewEventActivity
。
因此,通过扩展 Activity
在您的应用程序中创建 ViewEventActivity
class
同时在 AndroidManifest.xml
中添加 ViewEventActivity
class 作为 Activity:
<activity
android:name=".ViewEventActivity"
...
/>
我的代码源是https://developer.android.com/training/wearables/notifications/creating.html
在此示例代码中,第二部分 NotificationCompat 工作得很好..但我在 MainActivity.class 中有此代码,它给出了一个错误 "ViewEventActivity.class is not recognised"
现在这是什么ViewEventActivity.class,在哪里添加它以及如何实现它
代码片段::
int notificationId = 001;
// Build intent for notification content
Intent viewIntent = new Intent(this, ViewEventActivity.class);
viewIntent.putExtra(EXTRA_EVENT_ID, eventId);
PendingIntent viewPendingIntent =
PendingIntent.getActivity(this, 0, viewIntent, 0);
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_event)
.setContentTitle(eventTitle)
.setContentText(eventLocation)
.setContentIntent(viewPendingIntent);
// Get an instance of the NotificationManager service
NotificationManagerCompat notificationManager =
NotificationManagerCompat.from(this);
// Build the notification and issues it with notification manager.
notificationManager.notify(notificationId, notificationBuilder.build());
任何建议都会有很大帮助
替换
Intent viewIntent = new Intent(this, ViewEventActivity.class);
与
Intent viewIntent = new Intent();
这就是在单击 Notification.Its 时启动 Activity 的示例代码,与 Android 无关 API.if 您希望在单击时启动任何 Activity然后用 ViewEventActivity.class
替换 Activity
否则忽略它
"ViewEventActivity.class is not recognized"
ViewEventActivity
与任何 API 的 class 无关。所以你需要创建你自己的class,你想在通知点击时用任何名字打开它,而不是像其他class一样ViewEventActivity
。
因此,通过扩展 Activity
ViewEventActivity
class
同时在 AndroidManifest.xml
中添加 ViewEventActivity
class 作为 Activity:
<activity
android:name=".ViewEventActivity"
...
/>