Android通知远程查看错误

时间:2013-12-28 00:28:14

标签: android crash notifications

我有一个显示的通知。它在运行Vanilla JB的GS3上完美运行。当我尝试在Android 3.1模拟器上运行它时,崩溃时出现以下异常。 这不是自定义通知

12-28 00:26:05.239: E/AndroidRuntime(417): android.app.RemoteServiceException: Bad notification posted from package XX: Couldn't expand RemoteViews for: StatusBarNotification(package=XX id=0 tag=null notification=Notification(contentView=XX/0x1090087 vibrate=[500,500],sound=content://settings/system/notification_sound,defaults=0x0,flags=0x11) priority=0)

这是我的代码:

 public static void generateNotification(Context context, String message) {
    // Show the notification
    NotificationManager   notificationManager = (NotificationManager) context
            .getSystemService(Context.NOTIFICATION_SERVICE);

    Drawable largeIcon = context.getResources().getDrawable(R.drawable.ic_launcher);

    Builder builder = new NotificationCompat.Builder(context);

    builder.setContentTitle("XX");
    builder.setContentText(message);
    builder.setSmallIcon(R.drawable.ic_stat_push).setLargeIcon(drawableToBitmap(largeIcon));
    builder.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION));
    builder.setLights(Color.RED, 1000, 1000);
    builder.setTicker("XX: " + message);
    builder.setVibrate(new long[] { 500, 500});


    Intent intent = new Intent(context, MainActivity.class);
    intent.setAction("android.intent.action.MAIN");
    intent.addCategory("android.intent.category.LAUNCHER");
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("message", message);

    PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, intent,
            PendingIntent.FLAG_CANCEL_CURRENT);

    builder.setContentIntent(pendingIntent);

    Notification notification = builder.build();
    notification.flags = Notification.FLAG_AUTO_CANCEL | Notification.FLAG_SHOW_LIGHTS;
    notificationManager.notify(0, notification);
}

0 个答案:

没有答案
相关问题