Android Question Delete SMS

Slacker

Active Member
Licensed User
Longtime User
Hello Folks, the questions are pretty simple ( to say... )

Could someone show me the better way to delete an sms message (or directly abort the intent after intercept it silently in background as shown in other threads) in Android < 4.4 version and in 4.4 version too ( in the latter after setting my app as default sms app to handle sms message as read in other threads) using a foreground service ?

Some snippet code would be appreciated.

Thank you guys !
 

bsnqt

Active Member
Licensed User
Longtime User
For Android < 4.4 you need to use BroadcastReceiver. The following code was in the forum earlier (I think from Erel) with just some minor modifications:

B4X:
If myintent.Action = "android.provider.Telephony.SMS_RECEIVED" Then
        If myintent.HasExtra("pdus") Then
            Broadcast.AbortBroadcast
            Dim messages() As Message
            messages = ParseSmsIntent(myintent)
                For i = 1 To messages.Length - 1
                      messages(0).Body = messages(0).Body & messages(i).Body
                Next
           Log(messages(0).Body)
        End If
    End If

As for Android = 4.4 see Intercept SMS messages without notification Android 4.4

 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
Thank you very much bsnqt. I guess this was the solution. In the thread you highlighted me, ( so in Android = 4.4) the solution seems to be setting the App as Default System App for SMS Handling. In this case, i've seen i should handle *all* the logics behind the scenes, so it should be my work to insert the message in System Database, i think.... should i rebuild/coding all the "actions" as the Default Android Sms App do ?

I'm concerning just to filter some sms messages, nothing more..... and it's just a damn to rebuild all just for apply this little behavior.
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
Yes Erel.... but the problem is not to prompt user to change default Messaging app ( it's pretty simple mandatory task if him wants to use the App ). Problems, is to rebuild/coding all the logic due i guess the custom App should be cover all the tasks as the system default one do.

So the question is:

Supposing i impose user to set my App as default Messaging App and him do this task; Should I re-create in my app all the logic as the System default one even i want just to filter some messages ??? :O
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
Erel, yes. But if an user who use 4.4 would be going to benefit an App to manage his privacy on his device, couldn't be any choice to set this App as default one, unless he wanted bypass SMS control by the App in itself. There are outhere a lots of Apps would manage the privacy level about calls and SMS stuff and this restriction in 4.4 means just 2 things: or re-implement all the logic in your APP setting it as default one about SMS, or you can abandon the SMS custom privacy level.

A good solution to overcome this ?

A minimal snippet of useful code which target to RE-CREATE the basilar functionalities to receive and store an SMS ( MMS also but in this case we are talking about SMS stuff ). This could be a robust bone which one could start from to apply some modifies subsequently, keeping the basilar operations inside an custom APP set as default Messaging app.

I think this could be a layer useful to all ones.
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
Ok Erel... this is a bad new.... but there's no any further chance i guess.

Could you tell me, if you know, why Google decides to apply this restriction ? For my view, it's a pointless restriction....
 
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
For my view, the policy to impose an user some restrictions it's not a good idea i think... is the user who *must* decide for what is better for him or not. Security should be a middle line between imposed restrictions and user's knowledge. What is the real sense when you give the opportunity to set a default Messaging App in place of to give any App the same capacity to handle SMS, but with less coding ?. Result: no help for end user, more work and problems for developers.
This restriction has no sense and should be removed.
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User
I fully agree with Erel, being afraid that you should create a very "comprehensive" apk and maybe it is even not enough. I am in very similar situation now. My app was just about to be launched but now I decided to never launch it. It has a (nearly) full functionality with inbox, sent box, draft box, filters, blacklist, call blocker, send new message, contacts etc... It is not a small snippet but a real application, and for me it can be a good replacement for native sms app. However, as Erel said, I think very few people will "want to switch from Android Messaging app or Hangouts to any other SMS handling app", or to my app. If I want to set it as default SMS and replace the native one, it is just because it is my own product. I am quite sure nobody wants to do so

@Slacker: Yes, you are correct when saying "Security should be a middle line between imposed restrictions and user's knowledge", but it seems that the majority of users cannot be as knowledgeable as developers (I mean, in term of "playing" with apps). Hence for the sake of safety, Google wants to restrict the users to choose only one among 2 options (1) the stock Messaging or (2) the third party one, which clearly has less chance, like my app. By doing so, they are pretty sure that only the native app can be used

You can PM me your email, I can send my apk to you to test (and tell me please, if you want to replace your stock Message with mine )
 
Last edited:
Upvote 0

Slacker

Active Member
Licensed User
Longtime User
Ok bsnqt, your APP - related to SMS stuff - could be of interesting for me. Regard the fact about user couldn't be enough motivated it's pretty questionable; if an user install an APP to create an additional privacy level, the motivation could be raised. So, this depends about the purpose you use an APP and install it. If you want an APP to create an additional privacy level including SMS Stuff, setting it as Default Messaging APP could be a natural and painless result. So the raw stuff is developer side, not end user side ( Clap Clap Google, Thank you ! ). I will send you a PM my contacts. Thank you of all
 
Upvote 0

marcick

Well-Known Member
Licensed User
Longtime User
You can PM me your email, I can send my apk to you to test (and tell me please, if you want to replace your stock Message with mine )

Hi bsnqt, same situation for me. My app must manage SMS and intercept some of them and was working so fine prior to 4.4.
Now to ensure compatibility with 4.4 I had to write a simple SMS module but as the number of SMS/chat grows I have very poor speed performances in scrolling/sorting SMS as the stock app does.
I'm interested to test your code and make a donation if suits my needings.
I can't find how to write you a PM, could you please do it and write me ?
Thanks
Marco
 
Upvote 0

bsnqt

Active Member
Licensed User
Longtime User

Just click on my avatar, a popup will appear and you click on "Start a new conversation". Anyway I have PM you already.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…