我正在进行FCM通知,因为我无法继续进行,因此我遇到了一个奇怪的问题。
以上是我创建的自定义通知。我需要显示/隐藏相应于“接受”或“拒绝”按钮单击的底部灰色视图。
我只能在使用下面的代码
单击“接受”或“拒绝”按钮时创建待定意图 // Using RemoteViews to bind custom layouts into Notification
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.custom_notifications);
// reject button click intent
Intent rejectIntent = new Intent(this, MainActivity.class);
PendingIntent rejectIntentPending = PendingIntent.getActivity(this, 0, rejectIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
// approve button click intent
Intent approveIntent = new Intent(this, SubActivity.class);
PendingIntent acceptIntentPending = PendingIntent.getActivity(this, 0, approveIntent,
PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
// Set Icon
.setSmallIcon(R.drawable.logo)
// Set Ticker Message
.setTicker("notification received")
// Dismiss Notification
.setAutoCancel(true)
//.setWhen(0)
// Set PendingIntent into Notification
.setContentIntent(pIntent)
// Set RemoteViews into Notification
// .setContent(remoteViews)
// Set Title
.setContentTitle("App Name")
// show big notification hint when app is open
//.setPriority(Notification.PRIORITY_MAX)
// Set Text
.setContentText(messageBody)
// Set Sound
.setSound(defaultSoundUri)
// notification button 2
.addAction(rejectAction)
// notification button 3
.addAction(approveAction)
// Set RemoteViews into Notification
.setContent(remoteViews);
但是如何处理View。任何帮助对我都有很大的帮助。
这是可能的情景......