当前位置: 首页 > 知识库问答 >
问题:

从包发布的错误通知无法展开RemoteViews

哈沛
2023-03-14
03-26 20:44:44.849: E/AndroidRuntime(12080): FATAL EXCEPTION: main
03-26 20:44:44.849: E/AndroidRuntime(12080): android.app.RemoteServiceException: Bad notification posted from package by.flipdev.vkspy: Couldn't expand RemoteViews for: StatusBarNotification(pkg=by.flipdev.vkspy id=1 tag=null score=0 notn=Notification(pri=0 contentView=by.flipdev.vkspy/0x1090071 vibrate=null sound=null defaults=0x0 flags=0x2 kind=[null]))
03-26 20:44:44.849: E/AndroidRuntime(12080):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1374)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at android.os.Handler.dispatchMessage(Handler.java:99)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at android.os.Looper.loop(Looper.java:137)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at android.app.ActivityThread.main(ActivityThread.java:4931)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at java.lang.reflect.Method.invokeNative(Native Method)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at java.lang.reflect.Method.invoke(Method.java:511)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:558)
03-26 20:44:44.849: E/AndroidRuntime(12080):    at dalvik.system.NativeStart.main(Native Method)
protected void addNotification(final Bitmap Avatar,
        final int small_Image_ID, final int notify_id, final String text,
        final String title, final Boolean ongoing, final Boolean ticker,
        final String tickerText, final Boolean autoCancel,
        final String notificationCategory, final int notificationValue) {

    try {

        final Intent notificationIntent = new Intent(
                getApplicationContext(), CheckerActivity.class);

        notificationIntent
                .putExtra(notificationCategory, notificationValue);
        notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
                | Intent.FLAG_ACTIVITY_SINGLE_TOP);

        final PendingIntent contentIntent = PendingIntent.getActivity(
                getApplicationContext(), notify_id, notificationIntent,
                PendingIntent.FLAG_UPDATE_CURRENT);

        final NotificationManager nm = (NotificationManager) context
                .getSystemService(Context.NOTIFICATION_SERVICE);


        final NotificationCompat.Builder builder = new NotificationCompat.Builder(
                context);
        if (Ticker) {
            builder.setContentIntent(contentIntent)
                    .setSmallIcon(small_Image_ID)
                    .setOngoing(ongoing)                    
                    .setLargeIcon(Avatar).setTicker(tickerText)                     
                    .setWhen(System.currentTimeMillis())
                    .setAutoCancel(AutoCancel).setContentTitle(title)
                    .setContentText(text); // Текст уведомления
        } else {
            builder.setContentIntent(contentIntent)
                    .setSmallIcon(small_Image_ID)
                    .setLargeIcon(avatar)                       
                    .setOngoing(ongoing)
                    .setWhen(System.currentTimeMillis())
                    .setAutoCancel(AutoCancel).setContentTitle(title) 
                    .setContentText(text); // Текст уведомления
        }

        final Notification n = builder.getNotification();

        nm.notify(notify_id, n);

    } catch (final Exception e) {
                    // TODO: add exception handling code
    }
}

共有1个答案

沈俊美
2023-03-14

当我设置大图标时,我注意到3.0模拟器上发生了这种情况。

所以,由于大图标只被4.0+设备使用,我通过检查构建版本是否>13来解决这个问题。如果是这样(并且只有这样),我设置大图标。

问题已经解决了。

 类似资料: