How to make ongoing wearable notification without "Mute App" action - android

I am trying to make player notification with play/stop actions that is ongoing. I manage to make ongoing notification on wearable but i can't figure out how to make it without Mute app action that added automatically for ongoing notifications. TuneIn, Google Play Music and PlayerFm somehow manage to do this so there is way i just can't find it. May be anyone know how to do this?

I will answer my own question. Apparently there is no way to do this trough Notification. What all those apps do - they use RemoteControlClient to achieve this.

Related

How do I mute notification sounds from a specific app using ADB?

Trying to stop "Kijiji" from making noise every time I get a reply but the app has no way to disable the notification sound.
Any way to disable the notification sounds via ADB? I know you can disable vibration for specific apps so I think you can disable notification sounds also.

Dismissing MediaStyle notifications

New Android MediaStyle notifications in Lollipop don't have a dismiss button. Looks like there is already a bug for it on Google Code.
Does anyone know what's a good workaround for this issue until the bug is resolved?
Should we just delay switching to MediaStyle? Or use one of the actions as the dismiss button?
Adding on to #ianhanniballake's answer:
For Pre-Lollipop use:
notificationBuilder.setStyle(new NotificationCompat.MediaStyle().setShowCancelButton(true).setCancelButtonIntent(createPlayIntent());
For post-Lollipop:
To start a media-player notification one must have surely used startForeground() to start the Media Service as a Foreground Service. The problem now is that this Service is not dismissible. EVEN IF we set the setOngoing(false).
The best practice followed is to make the Service dismissible in the paused state. To do that, when your Media Service receives a Pause state callback, call stopForeground(false). This stops the service, but keeps the notification alive. And it can now be dismissed.
Happy coding.
One mechanism which appears to work quite well is make the notification ongoing while music is playing and make it not ongoing (allowing it to be swipe dismissed) when the music is paused. This seems to be the technique that Google Music already uses.
Easy but probably not the most suitable solution is to just add an Action with a 'close' icon. Then simply provide a PendingIntent which will trigger when the icon is clicked:

Prevent WhatsApp from playing notification sound

maybe you know the problem, you're in a whatsapp group with many notifications about messages you don't care about.
To prevent turning off all notifications/sounds, how can i catch/hook the notifcation event from whatsapp, and maybe even discard a notification in the top bar ?
Thanks for any suggestions
You cannot monitor, control, override and dismiss notifications from another app in your own app.
However, in the WhatsApp specific case, you can mute the group from within the WhatsApp app, or even turn off group notifications entirely.

Alerting the user from a service (Android)

So, i have a service working in the background (when the application is closed) which connects to internet every 2 minutes and gets some data from a database, and if something's wrong i want to alert the user with some kind of a beep tone and a message on the screen or even better in the notification bar. Is it possible to do this and if yes, how?
I think the nicest solution would be to use a SystemBar Notification.
Using the Notification.Builder you can add a custom sound to your notification using setSound(Uri sound).
What you think of is called ´Notification´ in Android. You can find more information here on how to create some.

How to achieve this in Android?

I am looking at Avast, Lookout for example and I am trying to understand the concept of the implementation. So it is more like asking for direction for me.
Persistent App icon in Notification bar.
Am I correct to say there are function NotificationManager is able to do it?
Scan virus during app installation, I am not interested in virus scanning but the triggering mechanism.
Some kind of Android service bind to the main app?
Main app that can be bring up in the Notification menu.
A main app that remain trigger action to the bind services?
So what do I need to read to understand? NoticationManager, Services and ??
In short, I want to load a icon in the notification bar that can bring up my app. There is a background service that perform specific task for a set interval.
Yep, NotificationManager and Notification can help you with that.
You just need to create the notification with flag FLAG_ONGOING_EVENT (to make it persistent). Even better if your service IS REALLY performing some long-running task, if so, you can start your service via Service.startForeground which needs some 'ongoing' notification for running (notification is required to notify the user that there is some work going now).
For triggering app install event, you can use BroadcastReceiver with filter by Intent.ACTION_PACKAGE_ADDED.

Categories

Resources