I want to send data from intent if my intent is null then simple open my main activity. This is my tryout but its not work for me.
From one activity to send
intent = new Intent(this, MainActivity.class);
intent.putExtra("androidkey",body);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
and receive time
String uid;
Intent intent = getIntent();
uid = intent.getStringExtra("androidkey");
Oncreate method of main activity
if (uid.equals("hello")){
startActivity(new Intent(MainActivity.this, About.class));
}else if (uid.equals("")||uid.equals(null)){
startActivity(new Intent(MainActivity.this, MainActivity.class));
}
Please tell me the solution for this because its crash my application.
what actually i want to do in my code is
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
if(remoteMessage.getData().size() > 0) {
Log.d(TAG, "Message data: " + remoteMessage.getData());
sendNotification(remoteMessage.getData().get("message"));
}
//Check if the message contains notification
if(remoteMessage.getNotification() != null) {
Log.d(TAG, "Mesage body:" + remoteMessage.getNotification().getBody());
sendNotification(remoteMessage.getNotification().getBody());
}
}
private void sendNotification(String body) {
if (body.equals("Image Upload Successfully")){
intent= new Intent(this, Image_Gallery.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}else if (body.equals("Video Upload Successfully")){
intent = new Intent(this, Video_Gallary.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}else if (body.equals("Home Work Are Uploaded")){
intent = new Intent(this, HomeWork.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
}
when my app is in foreground and notification arrived its open perfect page but when application is not in foreground it's open Mainactivity
so please tell me what should i can do for that..?