gpt4 book ai didi

android - 通知 Android 3.0

转载 作者:行者123 更新时间:2023-11-29 00:48:02 24 4
gpt4 key购买 nike

当我尝试创建通知时,我的应用程序总是崩溃,仅在 Android 3.0 上崩溃。

03-05 21:23:00.774: ERROR/ActivityManager(66): Activity Manager Crash
03-05 21:23:00.774: ERROR/ActivityManager(66): java.lang.IllegalArgumentException: Null intent at index 0
03-05 21:23:00.774: ERROR/ActivityManager(66): at com.android.server.am.ActivityManagerService.getIntentSender(ActivityManagerService.java:3907)
03-05 21:23:00.774: ERROR/ActivityManager(66): at android.app.ActivityManagerNative.onTransact(ActivityManagerNative.java:799)
03-05 21:23:00.774: ERROR/ActivityManager(66): at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:1516)
03-05 21:23:00.774: ERROR/ActivityManager(66): at android.os.Binder.execTransact(Binder.java:320)
03-05 21:23:00.774: ERROR/ActivityManager(66): at dalvik.system.NativeStart.run(Native Method)
03-05 21:23:00.784: WARN/dalvikvm(458): threadid=9: thread exiting with uncaught exception (group=0x40014760)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): FATAL EXCEPTION: Thread-10
03-05 21:23:00.814: ERROR/AndroidRuntime(458): java.lang.IllegalArgumentException: Null intent at index 0
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.os.Parcel.readException(Parcel.java:1326)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.os.Parcel.readException(Parcel.java:1276)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.app.ActivityManagerProxy.getIntentSender(ActivityManagerNative.java:2356)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at android.app.PendingIntent.getActivity(PendingIntent.java:195)
03-05 21:23:00.814: ERROR/AndroidRuntime(458): at com.perlapps.myantivirus.scanmethodes.UpdateDatabase$1.run(UpdateDatabase.java:244)

有人知道如何解决吗???

编辑:在 1.5 到 2.3 上完美运行

NotificationManager meinNM = (NotificationManager) oContext.getSystemService(Context.NOTIFICATION_SERVICE);
Notification meinNotofication = new Notification(R.drawable.icon,"HELLO",System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(oContext.getApplicationContext(),0, null, 0);
meinNotofication.setLatestEventInfo(oContext.getApplicationContext(),"HELLO","HELLO",pendingIntent);
meinNM.notify(97, meinNotofication);

最佳答案

使用有效的 PendingIntent。你的无效 -- null 不是 getActivity() 的有效第三个参数。此外,摆脱 getApplicationContext()——oContext 是一个 Context,这就是您所需要的。

关于android - 通知 Android 3.0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5206882/

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