Android的 - 坏的通知贴 - 无法扩大RemoteViews为:StatusBarNotification [英] android - Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification

查看:1009
本文介绍了Android的 - 坏的通知贴 - 无法扩大RemoteViews为:StatusBarNotification的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想用后在通知区域自定义视图的通知从IntentService,并获得了无法expant远程视窗错误。

I am trying to post a notification with custom view in the notification area from an IntentService, and getting the 'Couldn't expant RemoteView' error.

下面就是我在做的onCreate():

Here's what I am doing in onCreate():

mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
icon = R.drawable.icon;
tickerText = "data upload in progress";
contentView = new RemoteViews(getApplicationContext().getPackageName(), R.layout.notiflayout);
contentView.setImageViewResource(R.id.image, R.drawable.icon);
contentView.setTextViewText(R.id.text, "Hello");
contentView.setProgressBar(R.id.progressBar, 100, 10, false);
whatNext = PendingIntent.getActivity(getApplicationContext(), 0, new Intent(getApplicationContext(), starterActivity.class), 0);
notification = new Notification(icon, tickerText, System.currentTimeMillis());
notification.contentView = contentView;
notification.contentIntent = whatNext;

我打电话从OnHandleIntent()通知(),和取消通知中的OnDestroy()。

I am calling notify() from OnHandleIntent(), and canceling the notifications in OnDestroy().

我已验证该code工作在一个独立的应用程序,它不具有IntentService。在IntentService这样做以某种方式给予麻烦。

I have verified that this code works in an independent app, which does not have an IntentService. Doing this in an IntentService is somehow giving trouble.

可能有人请解释一下它是什么,我做错了什么?

Could someone please explain what is it that I am doing wrong?

谢谢!

推荐答案

那么错误是由于ResourceNotFound异常。我得到了'不能夸大视图的通知的消息。

Well the error was due to ResourceNotFound Exception. I was getting the 'couldn't inflate view for notification' message.

我不停地挖,并按照这些建议 的固定我的问题。我改名绘制-MDPI来绘制的。

I kept digging, and following the advice here fixed my problem. I renamed drawable-mdpi to drawable.

和,确保了code的工作后,我改变了文件夹名称回绘制,MDPI。事情仍在工作,让我相信,一个清洁工程其次是构建将有固定的问题。

AND, after making sure that the code worked, I changed the folder name back to drawable-mdpi. Things are still working, making me believe that a 'Clean Project' followed by Build would have fixed the problem.

希望这有助于。

这篇关于Android的 - 坏的通知贴 - 无法扩大RemoteViews为:StatusBarNotification的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆