简体   繁体   中英

Unable to send SMS with Dual Sim phone in Android

I'm developing an Android app that sends SMS to customers, I'm using a Sony XPERIA T2 Ultra Dual with Android 5.1.1.

This is my code:

           SmsManager smsManager
                    = SmsManager
                        .getSmsManagerForSubscriptionId(subscriptionId);

            smsManager.sendTextMessage( sms.getNumber(), null,
                                        sms.getContent(), sentPI, deliveredPI);

The messages are located in Messages App, but they're marked as unsent. I' ve been trying to add message center number as scAddress param, but It doesn't work. I tested all solutions in stackoverflow but nothing works. Anyone has an idea?

Thanks!

Finally I found the solution.

My app manifest was this:

<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.RECEIVE_SMS" />

But it also has to have this:

<uses-permission-sdk-23 android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission-sdk-23 android:name="android.permission.RECEIVE_SMS"/>
<uses-permission-sdk-23 android:name="android.permission.SEND_SMS"/>
<uses-permission-sdk-23 android:name="android.permission.INTERNET" />
<uses-permission-sdk-23 android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM