0

I do own according to the notification bar: http://developer.android.com/guide/topics/ui/notifiers/notifications.html

I do like the tutorial :

            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);

There are errors in the lines:

            NotificationIntent Intent = new Intent(BatteryInfoService.this,
                    BatteryInfoActivity.class);
            ContentIntent PendingIntent = PendingIntent.getActivity(ta, 0,
                    notificationIntent, 0);
            notification.contentIntent = contentIntent;

Errors:

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
Defuzer
  • 119
  • 2
  • 14

1 Answers1

2

Replace NotificationIntent with Intent (android does not provide NotificationIntent, unless its a custom class).

what you are looking for is

Intent notificationIntent = new Intent(BatteryInfoService.this,BatteryInfoActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);

Please read the tutorial carefully. Intent and PendingIntent are android Classes where as NotificationIntent and ContentIntent are not. If you have made custom classes under those names and you can import the appropriate packages.

Gan
  • 1,349
  • 2
  • 10
  • 27
  • The method getActivity(Context, int, Intent, int) in the type PendingIntent is not applicable for the arguments (new BroadcastReceiver(){}, int, Intent, int) – Defuzer Sep 07 '12 at 15:09
  • 1
    try "MyClass.this" instead of "this" if you are using this inside a broadcast receiver. this was you will pass the context of the activity correctly. – Gan Sep 07 '12 at 15:12