How to prevent incoming messages by reaching the native inbox in android? - android

I am developing the app which holds the messages in it's own inbox rather than the native inbox.
This can be achieved only if the incoming messages are prevented from reaching the native inbox.
There is some attribute android:priority in <intent-filter>, by which message can be first received by current receiver than others.
But I do not know how to do it properly, does anyone know?

I assume you mean SMS messages? The best, and only AFAIK, is to receive the message via registering the proper BroadcastReceiver object, copying the message into your database, marking it is read in the SMS ContentProvider and then deleting it from the SMS ContentProvider. Check out this article on how to receive SMS messages and then check out this SO post on how to use the SMS content provider.
Edit I actually stand corrected, there is another method that I've had sometimes limited success with. In the BroadcastReceiver you can call the abortBroadcast() method to cancel the broadcast. The important thing here is that you register your receiver with an intent filter that has a higher priority (say, 100) so that it receives the SMS before anybody else does.

Related

SMS message is not present in inbox after receiving in Kitkat

I'm creating little sms app, and after receiving it with my Broadcast receiver it is supposed to be present in inbox and it should be accessible to other sms apps as well, but it is not. It looks like no message was received at all. This issue occurs only when my app is default SMS app. Do I need to manually add received SMS to inbox after receiving it?
Do I need to manually add received SMS to inbox after receiving it?
Yes. The default SMS app is responsible for writing incoming messages to the Provider.
Reference

SMS BroadcastReceiver for multiple SMS in android

I am new in Android development and I'm doing an SMS app that receives multiple SMSes i.e notification SMS that's captured into the ListView and another SMS that contains the location of the sender for use in displaying the sender's location on google map.I've managed the first part,how do I listen again for the second SMS using the BroadcastReceiver...In other words how to listen for an incoming SMS when multiple different SMSes are expected.
If you impleted correctly the BroadCastReceiver you shouldnt worry about the second time, it would be fired automatically. You should post your code to have more information.
Welcome to Android development!
In order to receive incoming SMS's, you need to use the BroadcastReceiver mechanism that listens to incoming SMS's intent.
But, If you want to be sure that the message is going throw your app before it gets into the System's database, you have to give your BroadcastReceiver's Class a high priority on the manifest.
Good Luck.

With SMS receiver - how can I both abort propagation and still have it saved to content provider?

I'm writing an application that is intercepting some of the SMS mesasges and displays special notifications for them. In this light there is really no need for an additional notification in the status bar or on the screen from the "standard" SMS service. But just to be safe I want the message to not be lost and still show in user's message history.
Is there a way to do this?
I have to guess how you handle your SMS Received Broadcast, but i think you call abortBroadcast(); after you received the sms.
Otherwise the Broadcast would be forwarded to the next receiver, for example the stock sms app.
If you abort the Broadcast with a higher receiver priority, your app will interrupt incoming sms and the stock sms app is not able to save them into the history.
I hope this will help you.

Android and consume SMS

I write application which will get data from received SMS. This is data only for application and I dont want to user can read this message. Is possible to consume SMS just after get data from them to prevent user from reading this SMS? Thanks for any help.
You will need a sms receiver see http://davanum.wordpress.com/2007/12/15/android-listen-for-incoming-sms-messages/
Maybe you need also to delete the received sms.
Yes, this is easy to do. See my answer here for how to do this:
SMS receive with no notification
Once you've confirmed that the SMS is one of your special ones, you just need to call abortBroadcast() to stop it going into the user's inbox:
// Stop it being passed to the main Messaging inbox
abortBroadcast();
You should also be aware that the SMS receiver will not intercept SMS messages sent to the user's Google Voice number, as by default those messages will be downloaded over the data connection and displayed by the Google Voice app. If their Google Voice number is configured to forward the SMSs to the phone then those will be handled fine by the SMS receiver.

Android: SMS filter - Can you have priority listener for SMS messages?

I am trying to implement an app that will only listen for a certain header in the SMS.
(Parse the sms message and look for some header)
That's not hard to do.
The problem is once the app finds the header and knows this SMS is for me,
I don't want other app(that has broadcast listener on SMS) to receive SMS.
(for example, 'messages' to pop-up with sms message)
Is there a way to listen SMS before any other apps and decide to pass on to other app
or don't pass to other apps?
See one of the answers for the following question Can we delete an SMS in Android before it reaches the inbox?. It explains how to receive the BROADCAST, set the priority of your app so you receive the broadcast first so you could do your checks then cancel the broadcast so no other app receives it.
Read about BroadcastReceiver. You should use ordered broadcast - use android:priority attribute, and then call abortBroadcast() in your BroadcastReceiver.

Categories

Resources