我需要在通知上設置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,我想試試。 –