我正在尝试在通知区域中发布带有自定义视图的通知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;
我从 打来电话notify()
,onHandleIntent()
并取消了 中的通知onDestroy()
。
我已验证此代码在一个独立的应用程序中工作,该应用程序没有IntentService
. 这样做在IntentService
某种程度上会带来麻烦。
有人可以解释一下我做错了什么吗?