【发布时间】:2018-07-14 23:38:10
【问题描述】:
我正在尝试将 RemoteViews 传递给 intent,以便以后可以使用它来更新我的通知。但是,从 Intent 中获取 RemoteViews 时总是显示为 null。
基本上,单击按钮时,Notification 将减少或增加在通知中显示为textview 的权重值。
RemoteViews expandedView = new RemoteViews(context.getPackageName(), R.layout.remote_view_exercise_workout);
Intent addWeightIntent = new Intent(context, ExerciseWorkoutNotification.class);
addWeightIntent.putExtra("expandedView", expandedView);
expandedView.setOnClickPendingIntent(R.id.UpWeightButton, PendingIntent.getService(context, 1, addWeightIntent, PendingIntent.FLAG_UPDATE_CURRENT));
然后是意图处理:
protected void onHandleIntent(@Nullable Intent intent)
RemoteViews expandedView = (RemoteViews) intent.getSerializableExtra("expandedView");
updateWeightNotification(workout, expandedView, workoutPosition, operator);
但是,我的扩展视图在 intentHandle 上总是显示为 null。
我做错了什么还是有更好的方法?
【问题讨论】:
标签: android android-intent notifications