Send SMS message using non default SMS app on Android 4.4
Asked Answered
X

2

11

Can I send SMS using no default SMS app on Android 4.4 Kitkat?

It means, Can I send SMS without ability to write to SMS Provider?

I confused about that on Android 4.4 Kitkat.

I wonder I can just send SMS using non default SMS app or not.

Xhosa answered 24/10, 2013 at 8:4 Comment(1)
Read this document: android-developers.blogspot.tw/2013/10/…Mellissamellitz
S
11

You can send SMS even if your app isn't the default SMS app.

However, you won't be able to use the SMS provider.

That's the whole point of the new version - to make it clear to the user which app is allowed to use special SMS operations and have only one default app for this.

look at this text (taken from android developer blog) :

In consideration of some apps that do not want to behave as the default SMS app but still want to send messages, any app that has the SEND_SMS permission is still able to send SMS messages using SmsManager. If and only if an app is not selected as the default SMS app on Android 4.4, the system automatically writes the sent SMS messages to the SMS Provider (the default SMS app is always responsible for writing its sent messages to the SMS Provider).

so, in short, if all you need is to send and receive SMS, you can still do it.

however, some operations require that you will have your app as the default SMS app.

Silkstocking answered 3/11, 2013 at 9:50 Comment(20)
That's... If it hasn't ability to write to SMS Provider, it can't send SMS message, alright? So, Sending SMS using no default SMS app occur secure exception...?Xhosa
i've updated the answer. it seems you can do some basic things of SMS, but some operations require that your app would be the default one, and if that's the case (check by using "Telephony.Sms.getDefaultSmsPackage()") you should disable some features on your app.Silkstocking
also, about your question, i think that the default app is responsible of writing to the SMS Provider, but other apps can still send SMS.Silkstocking
@androiddeveloper Then how about write to inbox?will this below fail from my app? ContentValues values = new ContentValues(); values.put("date", System.currentTimeMillis()); values.put("address", sender); values.put("body", msg); getContentResolver().insert(Uri.parse("content://sms/inbox"), values);Cabinet
@Cabinet again, it's all guesses as i don't have kitkat, but as the API says, it should fail in case your app isn't the default one, so checking is needed.Silkstocking
@androiddeveloper hopefully he might write to default one.Will update after i check on 4.4 emulator or once i get N4 update.Cabinet
@android developer Above fails to write to Inbox.Only default SMS can write to provider.Cabinet
@Cabinet yes, as i've written and as the documentation says. only default SMS app can write to provider. however, other apps can still send&receive and perform some specific basic operations with SMS using the normal permissions.Silkstocking
I think Google gave us such shoddy information because they are trying to move into the space with Hangouts new sms feature, might as well have a leg up on their competition. The documentation and implementation is kind of lacking.Kiloliter
@digiholic you claim for some kind of conspiracy, but don't forget that google is known for not giving a lot of help in developing for Android. there are still so many topics that aren't covered well, don't get good tutorials and samples...Silkstocking
I was just poking fun at it and the lack of documentation on many of their major updates, heck even some of their old stuff too. This one just happens to correspond to their release of some of their own software. Even if they did conspire, we are at their mercy as devs any way.Kiloliter
@digiholic i believe it will get better over time, and even if it won't, other people will post enough information on the web to help you out...Silkstocking
Agreed. I've posted stuff on my blog when I can to help and have appreciated others that help too. Android development is a community in many ways.Kiloliter
Hi, this might be late but I have an issue related to same question ---> I am sending SMS using SmsManager, in Android L Emulator it is writing the sent SMS in SmsProvider automatically as my app is not default app... But, in KITKAT device sent SMS is not shown in "Messaging" app or may be not at all getting written to SmsProvider automatically. But as per blog by officials it must write to SmsProvider automatically.. am I doing something wrong or missing something or there is bug in the implementation by android ? Please help..Brandiebrandise
@digiholic Could you please show the blog post you've created? Maybe this could help some people here...Silkstocking
@android developer I've been slacking on updating my blog and need to get back on it. I'm knee deep in Lollipop right now. We had repeated trouble with continuity as is always seemed to vary by device and os. Yes, it is supposed to route automatically to the standard sms after a certain build, unless set as default. KitKat seemed to vary by device for us. Sorry, wish I could be more help.Kiloliter
@digiholic I don't understand, but this post was a long time ago, so I don't even remember how the SMS works on Kitkat...Silkstocking
@android developer Yeah, I'm with you. I was just referencing posting on my blog in response the previous comment in general and never posted a definitive answer to my blog. The good thing is that once we clear these hurdles, it should be better regulated across the board rather than sketched together like sms originally was on Android.Kiloliter
You cannot SEND, RECEIVE, WRITE, READ SMS, until your app is set as default SMS App. Your app manifest requests the SMS permission group (e.g. READ_SMS, SEND_SMS, WRITE_SMS, RECEIVE_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS) It must be actively registered as the default SMS or Assistant handler on the device. play.google.com/about/privacy-security-deception/permissionsSyblesybley
@SarthakSharma I'm pretty sure you do receive SMS messages using its permission, even if your app isn't the default SMS app. Check for example Tasker and other task automation apps. Even Sync.Me, which can scan SMS messages for phone numbers to search who has this number, or SMS validation done on many apps such as WhatsApp.Silkstocking
P
4

You can try this code:

PendingIntent sentPI = PendingIntent.getBroadcast(context, 0, new Intent(SENT), 0);

PendingIntent deliveredPI = PendingIntent.getBroadcast(context, 0, new Intent(DELIVERED), 0);

android.telephony.SmsManager.getDefault().sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI);

And in Manifest:

<uses-permission android:name="android.permission.SEND_SMS" />

It don't need confirmation from user if sending number don't 4,5,6 - digits.

Powdery answered 26/2, 2016 at 16:31 Comment(1)
Your app manifest requests the SMS permission group (e.g. READ_SMS, SEND_SMS, WRITE_SMS, RECEIVE_SMS, RECEIVE_WAP_PUSH, RECEIVE_MMS) It must be actively registered as the default SMS or Assistant handler on the device. play.google.com/about/privacy-security-deception/permissionsSyblesybley

© 2022 - 2024 — McMap. All rights reserved.