I want to open a specific activity on notification click. But when the application is in the background, it doent open. I am not even passing the extras(ie, the data). I just want to open the activity and according to user logged in, i do some tasks. I even tried to open my default launcher activity on the notification click and send the user to notification activity from there. Here's the code of my default launcher activity: PS: I am sending the message from the firebase console, but it only has title and body.
(This is the function i call after doing my network task:)
if (list.size()!=0){
for (int i=0;i<list.size();i++){
Users u=list.get(i);
//Toast.makeText(LoginActivity.this, "Logging in...", Toast.LENGTH_SHORT).show();
final Intent intent;
Bundle b=new Bundle();
// This is the solution i found to check whether the extras has the package name or not! But it doesnt seem to work.
if (Splashscreen.this.getIntent().getExtras() != null){
if (Splashscreen.this.getIntent().hasExtra("pushnotification") || Splashscreen.this.getIntent().getExtras().containsKey("com.tracecost")){
System.out.println("From notification----------->");
intent=new Intent(Splashscreen.this,NotificationReceivedActivity.class);
b.putString("pushnotification","yes");
}
else{
intent=new Intent(Splashscreen.this, ProjectSelection.class);
}
}
else{
intent=new Intent(Splashscreen.this, ProjectSelection.class);
}
b.putSerializable("user",u);
b.putSerializable("projectlist",plist);
intent.putExtras(b);
//logginDialog.dismiss();
Handler handler=new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
startActivity(intent);
finish();
}
},3500);
}
}
}```