我根據通知欄自己:http://developer.android.com/guide/topics/ui/notifiers/notifications.htmlAndroid的自定義通知欄
我喜歡的教程:
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
把意圖,而不是NotificationIntent。 –
它沒有幫助。 – Defuzer