1
(ここでは私の通知である)は、どのように私は私のメッセージ活動への私のプッシュ通知サービスとディスプレイからのメッセージ
public class MyFirebaseMessagingService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
Intent intent = new Intent(this, Message.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent,PendingIntent.FLAG_ONE_SHOT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
notificationBuilder.setContentTitle("FCM Notification");
notificationBuilder.setContentText(remoteMessage.getNotification().getBody());
notificationBuilder.setAutoCancel(true);
notificationBuilder.setSmallIcon(R.drawable.ic_event_note_black_24dp);
notificationBuilder.setContentIntent(pendingIntent);
NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(0,notificationBuilder.build());
}
}
と私のメッセージ活動
public class Message extends Activity {
private TextView textViewTitle;
private TextView textViewContent;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_message);
DisplayMetrics dm = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(dm);
int width = dm.widthPixels;
int height = dm.heightPixels;
textViewTitle = (TextView) findViewById(R.id.textViewTitle);
textViewContent = (TextView) findViewById(R.id.textViewTitle);
if (getIntent().getExtras() != null) {
//init message
String message = String.valueOf(getIntent().getExtras().get("message"));
String title = String.valueOf(getIntent().getExtras().get("title"));
//save the message
textViewTitle.save(getApplicationContext() , "message" , message);
textViewContent.save(getApplicationContext() , "title" , title);
startActivity(new Intent(getApplicationContext() , Message.class));
}
}
が良好に見える。それを出荷! – TooManyEduardos
ようこそスタックオーバーフロー!私は、その外観を改善するためにあなたのコードをフォーマットしました。将来は、テキストを左揃えにし、コードを少なくとも4スペースインデントすることによってコードをフォーマットすることができます。 –
助けてくれてありがとう....私は今それを試してみる....ありがとう.... –