how to disable system notifications in android using programming - android

While setting up the VPN connection in android phone, a system level notification with 'key' icon is generated by android system automatically. I am building an App which requires to set up a TUN interface internally but I am afraid of this notification which will be shown in notification bar by android system. I do not want android system to show up this notification to user.
Secondly a warning message "Attention" is also popped up while setting up a VPN connection. Again this message is also generated by android system.
I wanted my app to run quietly without showing any warning message and notification in notification bar. Any idea on how this thing can be achieved ??
Thanks

You cannot remove or disable it without changing the ROM. It is an android feature.

May be you should try something like How to cancel Android notifications or How to properly clear all notification once clicked in two words - something like this:
// Clear all notification
NotificationManager notificationManager = (NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}

You can use the Xposed plugin NotifyClean to remove any notification, even the android system notify.
If you want to do it from source, viewing their source code may help.

Related

Strange allow/deny question on Huawei 5.1 phone when showing notification

So it turns out that Huawei phones with 5.1 can't display MediaStyle notifications so while fixing that, I made a very simple notification test and I get a strange question asking Allow App Name to push messages to the notification panel.
I don't use push in any way, in fact the screenshot below is for an app that all it does is show a sample notification, nothing else.
How can I make it not show that?
This is the code:
Notification notification = new Notification.Builder(getApplicationContext())
.setSmallIcon(R.drawable.ic_launcher_background)
.setContentTitle("Track title")
.setContentText("Artist - Album")
.setOngoing(true)
.addAction(R.drawable.ic_add_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_android_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_archive_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_arrow_back_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_aspect_ratio_black_24dp, "fwd", pi)
.addAction(R.drawable.ic_fast_forward_black_24dp, "fwd", pi)
.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.vectors_525058875))
.setAutoCancel(false)
.build();
notificationManager.notify(300, notification);
This is the screenshot.
What am I doing wrong? I tried taking out all the actions, that didn't help. Took out title and context, that didn't help. Took out large icon, auto cancel, ongoing, etc, didn't help.
Please note that I am not using Push in any way and this doesn't seem to be related to that. Also I a using the support compat libraries to make my notification but on this example I didn't just to make sure that wasn't the issue.
Huawei's version of the Android OS has a custom feature that tries to spot apps doing annoying numbers of notifications.
Don't focus on the word "push". It doesn't mean "push notifications" in the technical sense of coming from the internet. It just is a verb, they could have said "allow app to create notifications" or "allow app to cause notifications" it's the same meaning.
Anyway, this is an OS feature, there is nothing you can do to avoid it except make sure you aren't spammy with your notifications. Unfortunately during development and testing you will often be triggering a lot of notifications, and the OS will detect your app is spammy. Don't worry about it. As long as your app works well for normal users it shouldn't happen.
It's Huawei customized Android OS feature. Long story short, you can't disable it.
I saw it a lot when I test my app. Huawei OS thinks your notification might annoy the end user(yourself, in this case) because it happened a lot.
You don't have to concern it๐Ÿ˜€
Your use deprecated constructor. Your must specify channel. Like this:
Notification.Builder builder = new NotificationCompat.Builder(context,"MyPerfectApplication")
Otherwise you use unknown chanel, possible you try to push in system channel.
it's indeed a custom check of EMUI, which enables the user to decide whether or not to have these custom notifications being pushed into the default notification channel, before a single one of these notifications had ever been displayed, when the first push is being attempted. it generally controls the notification settings of your app on Huawei devices, from within that notification panel. system & vendor applications are permitted to push notifications by default and therefore it won't ever ask the user for a double confirmation there. this has nothing to do with excessive notifications, because it is a precondition to even have these notifications pushed, no matter the amount.

Notification became junk with Clean Master app in Android

I am developing an Android app. In my app, I am doing push notification using Firebase. When I push from server, it shows notification in status bar in Android device. Pushing notification using Firebase is working fine.
I show notification like this in Android:
private void showMatchesNotification(String message)
{
notification = new NotificationCompat.Builder(getApplicationContext());
notification.setAutoCancel(true);
notification.setSmallIcon(R.mipmap.ic_launcher);
notification.setWhen(System.currentTimeMillis());
notification.setTicker(message);
notification.setContentTitle(getApplication().getResources().getString(R.string.app_name));
Intent i = new Intent(getApplicationContext(), MainActivity.class);
i.putExtra(MainActivity.FIELD_SELECTED_BOTTOM_TAB, MainActivity.BOTTOM_TAB_MATCHES);
PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(),0,i,PendingIntent.FLAG_UPDATE_CURRENT);
notification.setContentIntent(pendingIntent);
NotificationManager nm = (NotificationManager)getApplicationContext().getSystemService(getApplicationContext().NOTIFICATION_SERVICE);
nm.notify(3,notification.build());
}
The problem is when I show notification in Android, notification became junk in Clean Master app. Like below.
But when I tap on it, it is showing notifactions like this.
My question is, are notifications always marked as junk if Clean Master app is installed? Is there a way to push notification avoiding of becoming junks in Clean Master app? I want to show notification of my app in the status bar, and not in the junks. How can I do that?
Just disable the the 'junk notification" feature in CM. This is a feature you must have enabled in the first place, as it is not active on install. While I use CM, I've never enabled the 'junk notification' feature (might also be known as 'quiet notification"), I prefer to control notifications via each individual app setting. Otherwise, I don't really find them to be a problem.
When you enable Junk notification in CleanMaster app, it will put the notifications to junk of other apps. Click on the settings button in Notification cleaner on top right and you can see all apps which are enabled or disabled for notification cleaner. You can uncheck your app to prevent Cleanmaster from putting your notification to junk.

Is it possible to create a Notification which doesn't generate Heads up Notification, but will appear in lock-screen

I am currently in a project which develops a DECT-based android system based on Android 5.0.1, and need to add a mode which will bring up the Dialer App while the InCallUi App is running (when there is an incoming call). When the Dialer App is in the foreground, there will be an annoying headsup notification from the InCallUi App showing the incoming call information displaying on the top of the screen.
I want to ask if there is a way to hide the headsup notification, while in locked-screen the notification entry can still be seen?
I have tried to change the priority of the notification, as indicated in the following link that the headsup notification only presented when the priority is set to HIGH, MAX and FULL_SCREEN: "If a notification's priority is flagged as High, Max, or full-screen, it gets a peeking notification.", but when I set the priority to LOW or MIN the headsup notification still shows:
https://material.google.com/patterns/notifications.html#notifications-behavior
Can anyone help? thanks:)
No, this was a security bridge on older versions of android that provided a way to services to run as ForegroundServices without the user knowing, that issue was fixed in android 4.4.
You can see this SO thread for more information.

Show notification only on phone (not on Android Wear)

Is there any way to prevent a notification be shown on Android Wear device? I know it's possible by using setOngoing(true) but I don't want my notification to be ongoing.
you should call setLocalOnly(true) on the NotificationCompat.Builder.
From the documentation
Set whether or not this notification should not bridge to other
devices.
you can read more here

Creating Wearable notifications without the builder?

Is it possible to create wearable notifications without using the notification builder?
I already create a notification via new Notification on newer devices and would like to keep that code and still add the Wearable notification to my existing one. Is this possible, or is everything connected to the builder helper class for now?
It seems that there is no WearableNotifications.Builder class anymore in the newest SDK.
But you need to do nothing to simply let your Notification show on Android Wear Devices.
If you want to have a slightly better look for your Notifications you can use WearableExtender to add Android Wear specific actions, pages and layout options.
The WearableNotifications.Builder class is only needed if you want to add 'wearable extensions' to your notification. The normal notifications shown by your app are displayed also on the wearable connected to your device without any further integration work.

Categories

Resources