'App to sending multiple SMS doesn't work correct

I created my first app, and I have a small problem with my app I created an app sending multiple SMS with the same text to over 150 phone numbers. In my app, I use the default android app to send SMS. Only in my app, do I have many phone numbers and message texts.

In my app I have a few buttons, when I click on them then I run my functions that are similar to smsSemd() (the code below). When I click the button the 3 or 4 SMS are sent without any problems, but I can't more - in my default android app, I see an error ('the messages don't send) - when I click in the message - SMS will be sent.

I don't know why my app doesn't work correctly - I would like to send over 150 SMS in one click of the buttons in my app. Maybe one of you can help me?

My main code to send SMS:

public void smsSend(View view) {
  
    String msg = "more than 850 char to send.";

    ArrayList<PendingIntent> sentPendingIntents = new ArrayList<>();
    ArrayList<PendingIntent> deliveredPendingIntents = new ArrayList<>();

    @SuppressLint("UnspecifiedImmutableFlag") 
    PendingIntent sentPI = PendingIntent.getBroadcast(getApplicationContext(), 0, 
new Intent(getApplicationContext(), SmsSentReceiver.class), 0);

    @SuppressLint("UnspecifiedImmutableFlag") 
    PendingIntent deliveredPI = PendingIntent.getBroadcast(getApplicationContext(), 0, 
new Intent(getApplicationContext(), SmsDeliveredReceiver.class), 0);

    for (String phoneNumber : Numbers) {
        try {
            SmsManager sms = SmsManager.getDefault();
            ArrayList<String> parts = sms.divideMessage(msg);

            for (int i = 0; i < parts.size(); i++) {
                sentPendingIntents.add(i, sentPI);
                deliveredPendingIntents.add(i, deliveredPI);
            } 
             sms.sendMultipartTextMessage(phoneNumber, null, parts,
                    sentPendingIntents, deliveredPendingIntents);
            Toast.makeText(this, "Message send!", Toast.LENGTH_SHORT).show();
          
        } catch (Exception e) {
            e.printStackTrace();
            Toast.makeText(MainActivity.this, e.toString(), Toast.LENGTH_SHORT).show();
        }
    }
}

My AndroidManifest.xlm:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="pl.mk_it.sms">
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.BROADCAST_SMS"
    tools:ignore="ProtectedPermissions" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.READ_SYNC_STATS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>

<application
    android:fullBackupOnly="true"
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:usesCleartextTraffic="true"
    android:theme="@style/Theme.Sms"
    tools:targetApi="m">
    <activity android:name=".MainActivity"
        android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source