Remove sms notification in status bar - android

I'm building an sms handling application. I'm trying to remove only the notification icon from status bar, if received sms contains previously defined text such as "ALERT". So if the notification sound is open, sound will play as usual.
I can't use abortBroadcast() , because I want to store sms into the inbox. I don't want to delete it completely.
cancel(int) might work, but I don't know how to get id of notification that is created by native sms application of android.
I already tried cancelAll() since it is not my notification, it doesn't work.
Is there any way to do it? Thanks in advance
PS. Maybe I can use abortBroadcast() to block the notification icon at status bar, and then I can put sms into inbox programmatically, but it doesn't sound like a good practice for a simple task.

Related

Change default action for a Notification

I have created a app that sends and receives Sms messages and displays some info to the receiver. I want to know if its possible to trigger a class from my app when pressing on New Sms Notification, instead of the default action which is trigger Messaging app. Thanks in advance
No, you cannot change what another app's notifications do, for blindingly obvious security reasons.
You are certainly welcome to display your own Notification, though.
Please take a look at using permissions in your Application to allow you to receive the SMS message (which it sounds like is what your trying to do):
http://developer.android.com/reference/android/Manifest.permission.html#RECEIVE_SMS
If you use this in your application, you can receive the SMS, or even select your app as the default application to receive all SMS messages.
Also, if you would like to send the SMS message as well there is the SEND_SMS:
http://developer.android.com/reference/android/Manifest.permission.html#SEND_SMS
Additionally, once you add this ability you can Create your Notification and provide it to the Notification center the same way hangouts does, you will just have to implement a receiver and send a notification when an SMS is received.

Is there a way to make NotificationListenerService get notifications first?

I have a NotifcationListenerService that is receiving notifications, but in some cases, I want my app to be able to prevent the notification from making the default sound. For example, with SMS messages, I'd like to prevent the SMS notification from making the default noise, but only if I've handled the notification (I'm reading the notifications using TextToSpeech).
I know I can use cancelNotification(), but sometimes the notification gets posted to the notification bar (and thus the notification sound is played) before I can cancel it. Is there a way to set the priority of this listener?
Alternatively, I've created a BroadcastReceiver to listen for SMS_RECEIVED intents, but I can't seem to find a way to prevent JUST SMS notifications from making a sound. I can prevent ALL notifications from making a sound, but this isn't exactly what I want, since I'm not handling all notifications, and I don't want the user not to be notified for an event I haven't handled.

Can we perform an ACTION programmatically on a Notification from Notification Listener Service?

Is it possible to invoke an ACTION programatically on a Notification from a NotificationListenerService?
I have written a Notification Listener service that reads out all the incoming notifications and dismisses when done. But I'm not sure if we can perform any ACTIONs on the incoming notifications.
For eg: On a WhatsApp message notification I can read the package name, sender and message details but is there a way to send a reply back to the sender?
Currently Android Wear is doing this so I'm wondering if it is following a generic approach of acting upon a Notification or it has a specific API to WhatsApp service.
When ever a whatsapp notification is received via notification listerner service there is one another notification thats received (hidden) which has a tag value something like this XXXXXXX#s.whatsapp.net (xxxxxxx being the phonenumber), I think this somehow holds the key to sending a reply to this user.
I am working on other app logic, which does not require you to send back replies but I found this interesting but could not get enough time to check it myself.
Yes, you can do it by this function:
sbn.notification.actions[0].actionIntent.send()
Yes, we can perform actions on notifications. Pushbullet app on Android has an ability to reply to WhatsApp, Hangouts, Facebook messenger etc when user enters the message form desktop which means that there is a way. I am still trying to figure out how to do it.

How to programatically disable the Android Status Bar?

I am trying to make an SMS app in android. There are some messages which contents I want to keep hidden but as soon as I receive a message, android stausbar shows the contents of the message. How can I disable this programatically in my application?
Take a look at this question
Can we delete an SMS in Android before it reaches the inbox?
It shows you how to use a BroadcastReceiver to listen for SMS notifications and cancel them reaching other applications. This will allow your SMS app to display whatever notifications you wish, or don't.

Unread SMS tray notification stays after marking SMS as read

I've written an application that handles incoming SMS. Everything works great and also marking the processed SMS works. The only thing that doesn't seem to care is the tray notification. It still sits there in the tray and claims there is an unread message (just like the standard SMS app with its little green "1" does). I checked that the message actually is marked as read using the method used in the smspopup sample application, which seems to have the same problem. If I just say "close" on the received message, the tray icon is not updated. Do I miss something here? Do I have to send something like a notification to the tray that it should check again?
If you are talking about notification bar then application which sent that notification to android system should cancel it by calling notificationmanagers cancel(int id) method.
By making SMS read do not clears this notifications, when you go to that sms application(stock sms app may be) then that will call cancel notification method to clear notification bar.
SMS POPUP like apps can not clear notification bar of other stock SMS app.

Categories

Resources