android Ignore alerts only in certain activities (FCM)

Asked 2 years ago, Updated 2 years ago, 52 views

I implemented the firebase chat app and even implemented the notification I want to ignore the notification only in the chat activity because the notification rings in the chat activity!

I think Firebase Messaging Service can set it up, but I don't know how, so I'm asking you a question Please give us a good answer!

android firebase

2022-09-20 22:06

1 Answers

ActivityManager activityManager = (ActivityManager) getSystemService (ACTIVITY_SERVICE);
List info = activityManager.getRunningTasks(1); 
String activity = info.get(0).topActivity.getClassName();

You can bring one of the best activities with this. I think you can conditionally divide it so that you can call the Noti generation function only when it is not the same as the name of the activity in the chat window.

<uses-permission android:name="android.permission.GET_TASKS"/>

You need to give the above authority to manifest. Although it has been deprecated, this permission setting is not required in the latest version, and it needs to be added in the old version because it needs to be setIt's more


2022-09-20 22:06

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.