【发布时间】:2011-06-02 01:55:59
【问题描述】:
我正在尝试从IntentService 在通知区域中发布带有自定义视图的通知,并收到Couldn't expand RemoteView 错误。
这是我在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() 拨打notify(),并取消onDestroy() 中的通知。
我已验证此代码在没有IntentService 的独立应用程序中有效。在IntentService 中这样做会带来一些麻烦。
有人可以解释一下我做错了什么吗?
【问题讨论】:
标签: android android-service android-notifications