从包发布的错误通知无法展开RemoteViews [英] Bad notification posted from package Couldn't expand RemoteViews
本文介绍了从包发布的错误通知无法展开RemoteViews的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
03-26 20:44:44.849:E / AndroidRuntime(12080) :FATAL EXCEPTION:main
03-26 20:44:44.849:E / AndroidRuntime(12080):android.app.RemoteServiceException:从包by.flipdev.vkspy发布的错误通知:无法展开RemoteViews: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):在android.os.Handler.dispatchMessage(Handler.java:99)
03-26 20:44:44.849:E / AndroidRuntime(12080):在android.os.Looper .loop(Looper.java:137)
03-26 20:44:44.849:E / AndroidRuntime(12080):在android.app.ActivityThread.main(ActivityThread.java:4931)
03- 26 20:44:44.849:E / AndroidRun time(12080):at java.lang.reflect.Method.invokeNative(Native Method)
03-26 20:44:44.849:E / AndroidRuntime(12080):java.lang.reflect.Method.invoke Method.java:511)
03-26 20:44:44.849:E / AndroidRuntime(12080):在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,
/ pre>
final int small_Image_ID,final int notify_id, final String text,
final String title,final Boolean running,final Boolean ticker,
final String tickerText,final Boolean autoCancel,
final String notificationCategory,final int notificationValue){
尝试{
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)上下文
.getSystemService(Context.NOTIFICATION_SERVICE);
final NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
if(Ticker){
builder.setContentIntent(contentIntent)
.setSmallIcon(small_Image_ID)
.setOngoing(正在进行)
.setLargeIcon(Avatar).setTicker(tickerText )
.setWhen(System.currentTimeMillis())
.setAutoCancel(AutoCancel).setContentTitle(title)
.setContentText(text); //Текстуведомления
} else {
builder.setContentIntent(contentIntent)
.setSmallIcon(small_Image_ID)
.setLargeIcon(头像)
.setOngoing(正在进行)
.setWhen(System.currentTimeMillis())
.setAutoCancel(AutoCancel).setContentTitle(title)
.setContentText(text); //Текстуведомления
}
final通知n = builder.getNotification();
nm.notify(notify_id,n);
} catch(final Exception e){
// TODO:添加异常处理代码
}
}
为什么我的服务被杀死?
解决方案当我设置大图标时,这种情况发生在 3.0 仿真器。
所以,由于大图标仅由 4.0 + 设备使用,所以我通过检查Build版本是否> 13解决了这个问题。如果是(如果这样),我设置了大图标。
问题已经消失。
I have a problem. Some times my service is forcefully closed with this logcat:
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)
This is my code to add add notifications:
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 } }
Why is my service killed?
解决方案I noticed this happening on 3.0 emulators, when I set the Large Icon.
So, since the Large Icon is only used by 4.0+ devices, I solved this issue by checking if the Build version is > 13. If so (and only if so), I set the Large icon.
The problem has gone.
这篇关于从包发布的错误通知无法展开RemoteViews的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文