This is my code for sending SMS from my app:
protected void send() {
String no = mobileno.getText().toString();
String msg = message.getText().toString();
SmsManager sms = SmsManager.getDefault();
sms.sendTextMessage(no, null, msg, null, null);
Toast.makeText(getApplicationContext(), "sms sent", Toast.LENGTH_LONG).show();
}
my code for activity.xml is:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.spinnerex">
<uses-permission android:name="android.permission.SEND_SMS"/>
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
It shows SMS sent but I have not received any SMS. It shows no error but the SMS is not received.