Show notification only on phone (not on Android Wear) - android

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

Related

Set Firebase Notification to appear as Popup like whatsapp in Android studio

I am building an social media app in Android studio, this app uses firebase for push notifications, and notifications is working fine, that Is notifications shows on device's notification bar.
How can I change the behavior so that the notification can appear as popup when app is in foreground?
I want a persistent kind of notification, something like WhatsApp that can stay on top other apps so that users can quickly open notification on wherever they are on their phone.
On my research, the best i could get was to use this on my theme
But I do not have Theme.Holo.Dialog in my style and my aim is that the notification should appear even if app is not open.
Thank you for looking into this
You should use heads-up notifications
For this purposes you should use notification channel with high a importance: How to set importance in the notification channel.
In this answer you can find code sample, how to show notification in the channel with high importance(to show notification even if the app in the foreground):
https://stackoverflow.com/a/67953864/16210149
Hope it would be helpful.

how to disable system notifications in android using programming

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.

Pushing notification from smartphone to smartwatch

I'm developing an application where the user can create his own tasks and then he gets a notification when the time comes. So my question is how to push these notifications to his smartwatch? do I really need to code something or just write some wearable features and then synchronize them by using Bluetooth?
You don't need to code anything Android Wear specific. Just use the NotificationCompat.Builder to build your notification on your phone and it will show up on your Android Wear device.

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.

Access android notification led directly?

Is it possible to access the notification led without creating a new notification?
I would like to make it change colors over time but when I just change the color of an existing notification it is not smooth and only works when the device is locked.
No, you can't do this. Android API doesn't have any method which would allow it.

Categories

Resources