Cha*_*nya 43 java android android-service android-notifications
我试图从IntentService在通知区域中发布带有自定义视图的通知,并获取IntentService错误.
这是我在做的事情Couldn't expand RemoteView:
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;
Run Code Online (Sandbox Code Playgroud)
我打电话onCreate()给notify(),并取消通知onHandleIntent().
我已经验证此代码可以在一个独立的应用程序中运行,该应用程序没有onDestroy().这样做IntentService是以某种方式给予麻烦.
有人可以解释一下我做错了什么吗?
谢谢!
小智 12
由于未知原因,您不能在自定义远程视图的根视图中引用维度!所以你必须硬编码,android:layout_height="64dp"但如果你使用android:layout_height="@dimen/notification_height_that_64"它会给你Bad notification posted - Couldn't expand RemoteViews for: StatusBarNotification.我希望这个能帮上忙 :)
| 归档时间: |
|
| 查看次数: |
38674 次 |
| 最近记录: |