1

My android app sends SMS programmatically (usually triggered by a push message), and works as expected on numerous Android versions and devices. However on a new Oppo phone model CPH1851 I see a notification pop-up saying:

"[app name] will send SMS to [phone number]"

(where [app name] is the name of my app, and [phone number] is the number to which the app is sending an SMS to

enter image description here

The notification has a "Send" button and a "Cancel" button (latter with a decrementing timer)

Clearly this seems like another misguided attempt at Android security, without any thought to fragmentation and user-experience, but just looking to solve it.

Thanks for the help

PVS
  • 69
  • 9
  • This is System alert .. In most of the case you can not by-pass it .. Also google has changed guidelines for SMS permissions in production Check it out. – ADM May 23 '19 at 13:08
  • Very familiar with Play Store listing requirements for SMS-enabled apps, but that only determines whether you get to list it on Play Store. Can you be more specific about "System alert" -- any documentation? – PVS May 23 '19 at 16:07

2 Answers2

0

Please try this below code and add SEND_SMS Permission.

try {
            SmsManager smsManager = SmsManager.getDefault();

            ArrayList<String> parts = smsManager.divideMessage(sb.toString());
            //smsManager.sendTextMessage(phoneNumber, null, message, null, null);
            smsManager.sendMultipartTextMessage(phone, null, parts,
                    null, null);
            Toast.makeText(activity, "Send Message Successfully ", Toast.LENGTH_SHORT).show();

        } catch (Exception e) {
            Toast.makeText(getApplicationContext(), "SMS Failed !", Toast.LENGTH_LONG).show();
            e.printStackTrace();
        }

Below code wok for me in Oppo Phones try this

SmsManager sms = SmsManager.getDefault();
        List<String> messages = sms.divideMessage(message);
        for (String msg : messages) {

            PendingIntent sentIntent = PendingIntent.getBroadcast(this, 0, new Intent("SMS_SENT"), 0);
            PendingIntent deliveredIntent = PendingIntent.getBroadcast(this, 0, new Intent("SMS_DELIVERED"), 0);
            sms.sendTextMessage(phone, null, msg, sentIntent, deliveredIntent);
            Toast.makeText(activity, "Send Message Successfully", Toast.LENGTH_SHORT).show();

        }
Vicky
  • 19
  • 3
  • As I say in my post, my app works fine across numerous phones. Your code fragment is just the basic how-to-send-SMS – PVS May 23 '19 at 16:05
  • did you encounter the same problem as I describe on your Oppo phone? – PVS May 24 '19 at 20:26
0

Oppo's customized version of Android (called ColorOS) is the reason behind this trouble.

Settings/Security/Permissions/Send SMS shows you whether the app is "Allow"-ed to send SMS ("Ask" & "Forbid" are the other options). Setting this to "Allow" made the problem go away on one Oppo model. But not on another.

So the other option is to enable Developer Options, and turn on "Disable Permission Monitoring", at the very bottom of the list (this seems to turn off all of the ColorOS permission monitoring, but doesn't affect the basic Android permissioning).

PVS
  • 69
  • 9
  • Do you still face this problem? Do you still have the Screenshot? – Aman Verma Jan 16 '21 at 19:53
  • I solved it by having the user change their settings (as described above). Updated the OP with screenshot – PVS Jan 19 '21 at 00:44
  • In my App, I already have the SEND SMS permission but the Disable Permission monitoring is Off. Will the user still be able to see the prompt? I want to know if there is a way that the user can know what SMS is going to send before sending just like the SS above when sending using SMSmanager. – Aman Verma Jan 19 '21 at 16:56