我的 Firebasemessagingservice 类代码用于传递意图:
在onCreate()方法中,我的Fragment BaseActivity代码如下:
private void showNotification(String message){
Intent intent=new Intent(this, DrawerActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("data", message);
PendingIntent pendingIntent=PendingIntent.getActivity(this,0,intent,PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder=new NotificationCompat.Builder(this)
.setAutoCancel(true)
.setContentTitle("Registry")
.setContentText(message)
.setSmallIcon(R.drawable.com_facebook_button_send_icon_blue)
.setContentIntent(pendingIntent);
NotificationManager manager=(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
manager.notify(0,builder.build());
}
在onCreate()方法中,我的Fragment BaseActivity代码如下:
Intent notifyIntent = getIntent();
Bundle extras = notifyIntent.getExtras();
if (extras != null) {
replacefragment code;
}
它不能工作。