gpt4 book ai didi

java - android通知挂起 Intent 问题第三个参数类型错误

转载 作者:行者123 更新时间:2023-12-01 11:20:29 25 4
gpt4 key购买 nike

在我的应用程序上,我尝试向通知添加 Intent 时遇到错误。这是我的通知,这是我的代码...

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

}

我可以看到没有 Pendingintent 的通知。问题在于添加 Intent 时。这是我收到的错误

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)

编译器将错误标记为避免PendingIntentintentpending(Intentpendingintent)

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

任何帮助将非常感激:D。抱歉我的英语,我不是母语人士。

最佳答案

您需要调用 PendingIntent.getActivity() 而不是 PendingIntent.getActivities()

但即使这样也行不通,因为您需要使用显式 Intent(在其中设置 Activity 类名称)而不是隐式 Intent(仅限 Action)。

关于java - android通知挂起 Intent 问题第三个参数类型错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31295713/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com