'Activity does not open on android 11 when app is fully closed
I can open an activity by firebase FCM, but this works only for android <= 10, for android 11 it doesn't work. My app is completely closed, I only have the FCM service from firebase to open something. I don't know if the problem is occurring in i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Would the permission to overwrite other apps solve it?
public void onMessageReceived(@NonNull RemoteMessage remoteMessage) {
super.onMessageReceived(remoteMessage);
if(remoteMessage.getData().size() > 0){
for(String key : remoteMessage.getData().keySet()){
acao = remoteMessage.getData().get(key);
}
switch (acao){
case "screenStart":
Intent i = new Intent(this, DisplayActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.putExtra("key", "start");
startActivity(i);
break;
case "screenStop":
Intent in = new Intent(this, DisplayActivity.class);
in.putExtra("key", "stop");
in.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(in);
break;
default:
Log.d("TAG", "default................");
}
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
