我根据通知栏确实拥有:http://developer.android.com/guide/topics/ui/notifiers/notifications.html
我喜欢这个教程:
Notification notification = new Notification();
notification.flags = Notification.FLAG_ONGOING_EVENT;
notification.icon = icon;
RemoteViews contentView = new RemoteViews(getPackageName(),
R.layout.custom_notification);
contentView.setImageViewResource(R.id.image, R.drawable.b_10);
contentView.setTextViewText(R.id.title, "Custom zgłoszenie");
contentView.setTextViewText(R.id.text, "test test test");
notification.contentView = contentView;
NotificationIntent Intent = new Intent(BatteryInfoService.this,
BatteryInfoActivity.class);
ContentIntent PendingIntent = PendingIntent.getActivity(ta, 0,
notificationIntent, 0);
notification.contentIntent = contentIntent;
mNotificationManager.notify(BATTERY_ID, notification);
行中有错误:
NotificationIntent Intent = new Intent(BatteryInfoService.this,
BatteryInfoActivity.class);
ContentIntent PendingIntent = PendingIntent.getActivity(ta, 0,
notificationIntent, 0);
notification.contentIntent = contentIntent;
错误:
NotificationIntent cannot be resolved to a type
Multiple markers at this line
- ContentIntent cannot be resolved to
a type
- ta cannot be resolved to a variable
contentIntent cannot be resolved to a variable
答案 0 :(得分:2)
将NotificationIntent替换为Intent(android不提供NotificationIntent,除非它是自定义类)。
您正在寻找的是
Intent notificationIntent = new Intent(BatteryInfoService.this,BatteryInfoActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
请仔细阅读教程。 Intent和PendingIntent是android类,其中NotificationIntent和ContentIntent不是。如果您已在这些名称下创建自定义类,则可以导入相应的包。