0

On my app I'm getting an error trying to add a intent to a notification. Here is my notification here is my code...

public void notification(Context context,Bitmap bpm,File imagen)
{


    Intent pendingintent = new Intent();
    pendingintent.setAction(Intent.ACTION_VIEW);
    pendingintent.setDataAndType(Uri.fromFile(imagen),"image/*");
            //new Intent(Intent.ACTION_VIEW, Uri.parse(imagen.getAbsolutePath()));
    //context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(imagen.getAbsolutePath()))); /** replace with your own uri */
    PendingIntent intentpending = PendingIntent.getActivities(this.context,0,pendingintent,0);

    NotificationManager notification = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);


    Notification noti = new Notification.Builder(context)
            .setContentTitle("Nueva Pandi foto!")
            .setContentText("Foto recibida, clic para ver")
            .setSmallIcon(R.drawable.pandacamara)
            .setContentIntent(intentpending)
            .setLargeIcon(bpm)
            .setSound(Uri.parse("android.resource://aircam.prueba"+R.raw.sonidopanda))
            .setLights(-256, 100, 100)
            .build();
    notification.notify(0,noti);

}

I am able to see the notification whithout the Pendingintent. The problem is when adding the intent. This is the error I am getting

Error:(232, 52) error: no suitable method found for getActivities(Context,int,Intent,int) method PendingIntent.getActivities(Context,int,Intent[],int,Bundle) is not applicable (actual and formal argument lists differ in length) method PendingIntent.getActivities(Context,int,Intent[],int) is not applicable (actual argument Intent cannot be converted to Intent[] by method invocation conversion)

Compiler mark an error avobe PendingIntent intentpending (Intent pendingintent)

Wrong 3rd argument type found android.content.intent expected android.content.intent[]

Any help will be very apretiated :D. Sorry for my english, I am not a native speaker.

Noel Carcases
  • 711
  • 1
  • 7
  • 27

1 Answers1

1

You need to call PendingIntent.getActivity() instead of PendingIntent.getActivities()

But even that will not work because you need to use an explicit Intent (where you set the Activity class name) instead of an implicit intent (Action only).

BladeCoder
  • 12,779
  • 3
  • 59
  • 51
  • great! it work perfectly fine whit my code whit your recomendations. Now I am able to see the recived image when notification is clicked. – Noel Carcases Jul 08 '15 at 15:20