文档开发者中心
我的

Android8.0系统显示Notifacation偶尔会抛出RemoteServiceException异常


正常调用notification,会出现如下bug。非必现。线上出现概率还挺大,请帮忙看下
目前只出现在Android8.0系统上。机型有:华为荣耀6x,华为mate 9Pro,华为P9 plus,荣耀8青春版等等,其他非华为品牌不会出现,目前这种非必现bug出现频率挺高的,影响挺大
android.app.RemoteServiceException: Bad notification posted from package com.xxx.xxx: Couldn´t inflate contentViewsandroid.content.res.Resources$NotFoundException: Resource ID #0x7f030049        
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2101)        
at android.os.Handler.dispatchMessage(Handler.java:108)        
at android.os.Looper.loop(Looper.java:166)        
at android.app.ActivityThread.main(ActivityThread.java:7425)        
at java.lang.reflect.Method.invoke(Native Method)        
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:245)        
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:921)

说明:0x7f030049为RemoteView的自定义布局id(布局用的都是普通的TextView,ImageView,无ListView,自定义控件等),这个RemoteView设置给notification。其他RemoteView的布局id也会抛出类似异常。

点赞
收藏
回复
8
分享
举报
浏览2592 发布于2018-11-08 11:43未知归属地
全部评论
最多点赞
最新发布
最早发布
请问大佬最后怎么解决的这个问题呢?我们现在也遇到一样的问题
8楼回复于2023-07-05 13:38 未知归属地
是否和简书这个帖子一样的问题?RemoteView 资源id 引发的错误
7楼回复于2019-06-05 05:43 未知归属地
huafans01189367865 发表于 2018-12-3 16:22
能给个回复吗 同胞们

请问楼主解决了吗
6楼回复于2019-02-25 09:01 未知归属地
能给个回复吗 同胞们
5楼回复于2018-12-03 08:22 未知归属地
花粉Eva 发表于 2018-11-9 10:57
push?

下面有调用方式
4楼回复于2018-11-12 02:51 未知归属地
这是创建Notifaction的方式,上面抛出的异常就是R.layout.status_bar_download_both这个资源id找不到

nNotificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
RemoteViews views = new RemoteViews(mContext.getPackageName(), R.layout.status_bar_download_both);
mDownloadNotification = new Notification();
mDownloadNotification.flags |= Notification.FLAG_AUTO_CANCEL;
mDownloadNotification.contentView = views;
Intent intent = new Intent(MusicUtils.VIEW_UIMAIN_FILETER).addFlags(
        Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
Bundle mExtraBundle = new Bundle();
mExtraBundle.putBoolean(DOWNLOAD_NOTIFICATION_INTENT, true);
intent.putExtras(mExtraBundle);
mDownloadNotification.contentIntent =
        PendingIntent.getActivity(mContext,
requestCode, intent, 0);

3楼编辑于2018-11-09 06:12 未知归属地
花粉Eva 发表于 2018-11-9 10:57
push?

不一定是推送,比如说下载进度的notification,播放音乐时显示的notification都有可能出现如上问题
2楼回复于2018-11-09 06:05 未知归属地
push?
1楼回复于2018-11-09 02:57 未知归属地
写回答
新增插入模板功能
一键使用模板,快速填写内容,轻松发帖~
知道了
  • 为了保障您的信息安全,请勿上传您的敏感个人信息(如您的密码等信息)和您的敏感资产信息(如关键源代码、签名私钥、调试安装包、业务日志等信息),且您需自行承担由此产生的信息泄露等安全风险。
  • 如您发布的内容为转载内容,请注明内容来源。

我要发帖子

了解社区公约,与您携手共创和谐专业的开发者社区。