title: SMS andrio studio permission issue
body: <p>so,  I have this SMS application in android studio. When running this first time it pop:ed up a window asking for permission and so the SMS got sent. But later on it never asks for permissions and the SMS dosent send. Can anyone help me? </p>
  
  <p>this is my main class. </p>
  
  <pre><code>package com.example.xbhatti.sms4;
  
  import android.Manifest;
  import android.content.pm.PackageManager;
  import android.os.Bundle;
  import android.app.Activity;
  
  import android.support.v4.app.ActivityCompat;
  import android.support.v4.content.ContextCompat;
  import android.telephony.SmsManager;
  
  import android.util.Log;
  import android.view.Menu;
  import android.view.View;
  
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.Toast;
  
   public class MainActivity extends Activity {
  private static final int MY_PERMISSIONS_REQUEST_SEND_SMS =0 ;
  Button sendBtn;
  EditText txtphoneNo;
  EditText txtMessage;
  String phoneNo;
  String message;
  
  @Override
      public void onRequestPermissionsResult(int requestCode,String permissions[], int[] grantResults) {
      switch (requestCode) {
          case MY_PERMISSIONS_REQUEST_SEND_SMS: {
              if (grantResults.length &gt; 0
                      &amp;&amp; grantResults[0] == PackageManager.PERMISSION_GRANTED) {
                  SmsManager smsManager = SmsManager.getDefault();
                  smsManager.sendTextMessage(phoneNo, null, message, null, null);
                  Toast.makeText(getApplicationContext(), "SMS sent.",
                          Toast.LENGTH_LONG).show();
              } else {
                  Toast.makeText(getApplicationContext(),
                          "SMS faild, please try again.", Toast.LENGTH_LONG).show();
                  return;
              }
          }
      }
  
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.activity_main);
  
      sendBtn = (Button) findViewById(R.id.btnSendSMS);
      txtphoneNo = (EditText) findViewById(R.id.editText);
      txtMessage = (EditText) findViewById(R.id.editText2);
  
      sendBtn.setOnClickListener(new View.OnClickListener() {
          public void onClick(View view) {
              sendSMSMessage();
          }
      });
  }
  
  
  
  protected void sendSMSMessage() {
      phoneNo = txtphoneNo.getText().toString();
      message = txtMessage.getText().toString();
  
      if (ContextCompat.checkSelfPermission(this,
              Manifest.permission.SEND_SMS)
              != PackageManager.PERMISSION_GRANTED) {
          if (ActivityCompat.shouldShowRequestPermissionRationale(this,
                  Manifest.permission.SEND_SMS)) {
          } else {
              ActivityCompat.requestPermissions(this,
                      new String[]{Manifest.permission.SEND_SMS},
                      MY_PERMISSIONS_REQUEST_SEND_SMS);
          }
      }
  }
  
  
  }
  </code></pre>
  
  <p>and this is my xml file </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      tools:context="com.example.xbhatti.sms4.MainActivity"&gt;
  
  &lt;TextView
      android:id="@+id/textView1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Sending SMS Example"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:textSize="30dp" /&gt;
  
  &lt;TextView
      android:id="@+id/textView2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Tutorials point "
      android:textColor="#ff87ff09"
      android:textSize="30dp"
      android:layout_below="@+id/textView1"
      android:layout_alignRight="@+id/imageButton"
      android:layout_alignEnd="@+id/imageButton" /&gt;
  
  &lt;ImageButton
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/imageButton"
      android:layout_below="@+id/textView2"
      android:layout_centerHorizontal="true" /&gt;
  
  &lt;EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/editText"
      android:hint="Enter Phone Number"
      android:phoneNumber="true"
      android:textColorHint="@color/abc_primary_text_material_dark"
      android:layout_below="@+id/imageButton"
      android:layout_centerHorizontal="true" /&gt;
  
  &lt;EditText
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:id="@+id/editText2"
      android:layout_below="@+id/editText"
      android:layout_alignLeft="@+id/editText"
      android:layout_alignStart="@+id/editText"
      android:textColorHint="@color/abc_primary_text_material_dark"
      android:layout_alignRight="@+id/imageButton"
      android:layout_alignEnd="@+id/imageButton"
      android:hint="Enter SMS" /&gt;
  
  &lt;Button
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="Send Sms"
      android:id="@+id/btnSendSMS"
      android:layout_below="@+id/editText2"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="48dp" /&gt;
  
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>and this is my mainfest xml file </p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.xbhatti.sms4"&gt;
  
      &lt;uses-permission android:name="android.permission.SEND_SMS" /&gt;
  
  
  &lt;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"&gt;
      &lt;activity android:name=".MainActivity"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
  
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>