0

MainActivity.java

Button sendTestSMSButton = (Button)findViewById(R.id.sendTestSMSButton);
        sendTestSMSButton.setOnClickListener(new View.OnClickListener()
        {
            @Override
            public void onClick(View v)
            {
                System.out.println("Send SMS");

                try
                {
                    SmsManager smsManager = SmsManager.getDefault();
                    smsManager.sendTextMessage("+972526855556", null, "shenkin", null, null);
                }

                catch (Exception e)
                 {
                    e.printStackTrace();
                }
             }

        });

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.smssong.admin.smstosong">

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="22" />
    <uses-permission android:name="android.permission.SEND_SMS" />

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        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><!-- ATTENTION: This was auto-generated to add Google Play services to your project for
     App Indexing.  See https://g.co/AppIndexing/AndroidStudio for more information. -->
        <meta-data
            android:name="com.google.android.gms.version"
            android:value="@integer/google_play_services_version" />
    </application>

</manifest>

I get error "Sending SMS message: uid 10063 does not have android.permission.SEND_SMS."

Even that in the AndroidManifest.xml there is code to enable the permission. What I am missing ?

user3879626
  • 127
  • 6
  • Possible duplicate of [Android permission doesn't work even if I have declared it](http://stackoverflow.com/questions/32635704/android-permission-doesnt-work-even-if-i-have-declared-it) – Mike M. Oct 23 '16 at 19:59
  • I am using emulator SDK 22 but still can not send sms – user3879626 Oct 25 '16 at 09:55
  • What exactly do you mean by "emulator SDK"? Do you mean you're running on Lollipop? – Mike M. Oct 25 '16 at 09:57
  • targetSdkVersion set to 22 since 23 does not allow to send SMS from android – user3879626 Oct 25 '16 at 10:02
  • If you're using Android Studio, the SDK versions you set in the manifest are overridden by the values in the build.gradle file. Look there to see what the `targetSdkVersion` is set to. Also, yes you can still send SMS with 23; you just need to handle runtime permissions if you're targeting that version or above. – Mike M. Oct 25 '16 at 10:04

1 Answers1

-1

There was permission error using illegal SDK

user3879626
  • 127
  • 6