我需要在通知上设置onclicklistener,以便我可以调用PHP文件并从我的数据库获取数据,然后将其设置为我的通知所打算的活动,你能给我一些线索吗?
我抬头看着其他问题,但我真的不明白如何做到这一点。 这里是我的代码时,我设置了通知:如何在通知上设置onclicklistener android
public class FirebaseMessagingService extends
com.google.firebase.messaging.FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
showNotification(remoteMessage.getData().get("message"));
}
private void showNotification(String message) {
Intent i = new Intent(this, ActivityRestaurantHistoryReservations.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("You have a new reservation !")
.setContentText(message)
.setSmallIcon(R.drawable.common_google_signin_btn_icon_dark)
.setContentIntent(pendingIntent);
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0, builder.build());
}
}
谢谢您的帮助
谢谢您unswer,我想试试。 –