java 数组长度异常_自定义通知:java.lang.RuntimeException:错误的数组长度

我想利用谷歌的样品用在我的Android应用程序的自定义通知这里(部分创建自定义通知布局).由于我使用了这个确切的代码,我RuntimeException每隔几次就会收到通知.

我的堆栈跟踪:

FATAL EXCEPTION: main

java.lang.RuntimeException: bad array lengths

at android.os.Parcel.readIntArray(Parcel.java:677)

at android.app.INotificationManager$Stub$Proxy.enqueueNotificationWithTag(INotificationManager.java:369)

at android.app.NotificationManager.notify(NotificationManager.java:110)

at android.app.NotificationManager.notify(NotificationManager.java:90)

at com.****.service.UpdateFeedService.notifyUpdateProgress(UpdateFeedService.java:266)

at com.****.service.task.PodcastUpdaterTask.onProgressUpdate(PodcastUpdaterTask.java:63)

at com.****.service.task.PodcastUpdaterTask.onProgressUpdate(PodcastUpdaterTask.java:1)

at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:432)

at android.os.Handler.dispatchMessage(Handler.java:99)

at android.os.Looper.loop(Looper.java:144)

at android.app.ActivityThread.main(ActivityThread.java:4937)

at java.lang.reflect.Method.invokeNative(Native Method)

at java.lang.reflect.Method.invoke(Method.java:521)

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)

at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)

at dalvik.system.NativeStart.main(Native Method)

我的代码:

private final Intent updateInProgressIntent = new Intent(this.context, PodcastListActivity.class);

private RemoteViews updateInProgressContentView = null;

private PendingIntent updateInProgressPendingIntent = null;

private Notification updateInProgressNotification = null;

...

@Override

public void onCreate() {

super.onCreate();

...

this.updateInProgressPendingIntent = PendingIntent.getActivity(this, UPDATE_INPROGRESS_NOTIFICATION_ID,

this.updateInProgressIntent, PendingIntent.FLAG_UPDATE_CURRENT);

this.updateInProgressContentView = new RemoteViews(getPackageName(), R.layout.custom_notification);

...

}

public void notifyUpdateProgress(final int index, final int size, final Podcast podcast) {

this.updateInProgressContentView.setImageViewBitmap(

R.id.image, ActivityHelper.getBitmap(context, podcast.getThumbnailAsset()));

this.updateInProgressContentView.setTextViewText(R.id.title, "some msg");

this.updateInProgressContentView.setTextViewText(R.id.text, podcast.getName());

this.updateInProgressNotification.contentView = this.updateInProgressContentView;

this.updateInProgressNotification.contentIntent = this.updateInProgressPendingIntent;

this.notificationManager.notify(UPDATE_INPROGRESS_NOTIFICATION_ID, this.updateInProgressNotification);

...

}

如果我用标准通知替换自定义通知(有setLatestEventInfo())我没有问题.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值