Android Java close derived Intent

I'm using Cordova Firebase plugin to handle the push notifications
The message is a JSON, if close is 0 the activity will start. But i can't close the derived intent if the close is 1.

For example:

public class FirebasePluginMessagingService extends FirebaseMessagingService {
    ...
    private static Intent doorbellIntent;
    ...
    public class FirebasePluginMessagingService extends FirebaseMessagingService {
        Map<String, String> data = remoteMessage.getData();

        for (Map.Entry<String, String> entry : data.entrySet()) {
            String key = entry.getKey();
            String value = entry.getValue();
            Log.w(TAG, key + " - " + value);
        }

        if (data.get("close").equals("1")){
            //This is what i'm need.
            return;
        }
      
        Intent dialogIntent = new Intent(this, DoorBellRinging.class);
        Bundle bundle = new Bundle();
        bundle.putString("homeString", relevantHomeString);
        bundle.putInt("streamId", doorPhoneId);
        bundle.putBoolean("ring", true);
        dialogIntent.putExtras(bundle);
        dialogIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(dialogIntent);
        doorbellIntent = dialogIntent;
    }
}


Read more here: https://stackoverflow.com/questions/65013086/android-java-close-derived-intent

Content Attribution

This content was originally published by benadzs at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: