How can a non-default Android app send SMS automatically without user interaction?


I’m developing an app that needs to send an SMS automatically when a certain event happens (e.g., a user action). The user should not have to interact with the phone after the event – the message must go out silently in the background.

The app is not and cannot be the default SMS app. I’m using SmsManager.sendTextMessage() from Kotlin (called via Flutter’s MethodChannel). It always fails with RESULT_ERROR_GENERIC_FAILURE. The SMS never gets sent.


What I’ve done (correctly)

  • Added <uses-permission android:name="android.permission.SEND_SMS" /> and also READ_PHONE_STATE, RECEIVE_SMS, READ_SMS.

  • Requested Permission.sms at runtime – it is granted.

  • The app runs a foreground service and has android:stopWithTask="false".

  • Phone numbers are in E.164 format (+1234567890).

  • Tested on real devices: Samsung Galaxy A10 (Android 11), Pixel 4 (Android 14), Xiaomi Redmi Note 10 (Android 12).


MainActivity.kt

private fun sendSms(phoneNumber: String, message: String, result: Result) { try { val smsManager = SmsManager.getDefault() val sentPI = PendingIntent.getBroadcast( this, 0, Intent("SMS_SENT"), PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE ) val deliveredPI = PendingIntent.getBroadcast( this, 0, Intent("SMS_DELIVERED"), PendingIntent.FLAG_ONE_SHOT or PendingIntent.FLAG_IMMUTABLE ) val receiver = object : BroadcastReceiver() { override fun onReceive(context: Context?, intent: Intent?) { when (getResultCode()) { Activity.RESULT_OK -> result.success(true) SmsManager.RESULT_ERROR_GENERIC_FAILURE -> { Log.e("SMS", "Generic failure") result.error("SMS_FAILED", "Generic failure", null) } else -> result.error("SMS_FAILED", "Unknown error", null) } unregisterReceiver(this) } } registerReceiver(receiver, IntentFilter("SMS_SENT")) smsManager.sendTextMessage(phoneNumber, null, message, sentPI, deliveredPI) } catch (e: Exception) { result.error("SMS_FAILED", e.message, null) } }

Everything I’ve tried (and why it didn’t work)

  • Basic sendTextMessage() – always generic failure.

  • Added all SMS‑related permissions – no change.

  • Requested runtime permission – granted, still fails.

  • Used sendTextMessageWithoutPersisting() (API 31+) – same failure.

  • Captured result code via BroadcastReceiver – code is 1 (generic failure).

  • Tested on multiple devices – all fail.

  • Ensured phone number format – correct.

  • Added WRITE_SMS permission – no effect.

  • Used the Flutter telephony_sms package (wraps same API) – same failure.

  • Opened the SMS composer (Intent.ACTION_VIEW) – works, but user must tap “Send” (not automatic).

  • Used WorkManager to retry – still generic failure.

The only time it worked was when I temporarily set my app as the default SMS app on the test device. Then the SMS sent automatically. But that’s not acceptable for my use case – users won’t change their default messaging app.


What I’ve read

Android’s SmsManager documentation doesn’t explicitly forbid non‑default apps from sending SMS automatically, but many Stack Overflow answers claim that since Android 4.4 (KitKat), only the default SMS app can do that. I’ve tried all the workarounds I could find – none worked.


My questions

  1. Is it actually possible for a non‑default SMS app to send an SMS automatically on Android 11–14? If yes, what am I missing – a hidden permission, a special intent flag, or something else?

  2. If it’s impossible, what is the recommended alternative for an app that must send a critical alert without user interaction? For example:

  • Cloud SMS gateway (Twilio, etc.) – requires internet and ongoing cost.

  • Open‑source gateway like TextBee – requires a dedicated Android phone.

  • Push notification to a trusted contact’s app (offline?)

  • Something else?


Environment

  • Flutter 3.24.0

  • Target SDK 34

  • Tested on Android 11, 12, 14

1
Apr 8 at 10:08 AM
User AvatarMikias Gebresilasie
#android#flutter#kotlin#sms#android-permissions

No answer found for this question yet.