title: Android Studio java.lang.IllegalStateException
body: <p>Hello I am trying to make an application using intents however whenever I want to use the work method it will print an error. I am a beginner to Android So I have no clue how to fix it </p>
  
  <p><strong>The Error :</strong></p>
  
  <pre><code>java.lang.IllegalStateException: Could not execute method of the activity
              at android.view.View$1.onClick(View.java:4007)
              at android.view.View.performClick(View.java:4756)
              at android.view.View$PerformClick.run(View.java:19749)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.reflect.InvocationTargetException
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at android.view.View$1.onClick(View.java:4002)
              at android.view.View.performClick(View.java:4756)
              at android.view.View$PerformClick.run(View.java:19749)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
              at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
       Caused by: java.lang.SecurityException: Permission Denial: starting Intent { act=android.intent.action.CALL dat=tel:xxxxxxxxx cmp=com.android.server.telecom/.CallActivity } from ProcessRecord{27530cd6 1787:edgaraxe.com.smartad/u0a58} (pid=1787, uid=10058) requires android.permission.CALL_PHONE
              at android.os.Parcel.readException(Parcel.java:1540)
              at android.os.Parcel.readException(Parcel.java:1493)
              at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:2395)
              at android.app.Instrumentation.execStartActivity(Instrumentation.java:1480)
              at android.app.Activity.startActivityForResult(Activity.java:3736)
              at android.app.Activity.startActivityForResult(Activity.java:3697)
              at android.app.Activity.startActivity(Activity.java:4007)
              at android.app.Activity.startActivity(Activity.java:3975)
              at edgaraxe.com.smartad.SecondPage.Work(SecondPage.java:44)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372)
              at android.view.View$1.onClick(View.java:4002)
              at android.view.View.performClick(View.java:4756)
              at android.view.View$PerformClick.run(View.java:19749)
              at android.os.Handler.handleCallback(Handler.java:739)
              at android.os.Handler.dispatchMessage(Handler.java:95)
              at android.os.Looper.loop(Looper.java:135)
              at android.app.ActivityThread.main(ActivityThread.java:5221)
              at java.lang.reflect.Method.invoke(Native Method)
              at java.lang.reflect.Method.invoke(Method.java:372
  </code></pre>
  
  <p>The method causing the issue :</p>
  
  <pre><code>public void Work (View view) {
      SharedPreferences share = getSharedPreferences(PREFS_TITLE, 0);
      String asd = share.getString("phone", "Phone not found");
      System.out.println(asd);
      Intent intent2 = new Intent(Intent.ACTION_CALL,Uri.parse("tel:"+asd));
      startActivity(intent2);
  }
  </code></pre>
  
  <p>The complete code can be found here : <a href="http://pastebin.com/mAhxUVDC" rel="nofollow">http://pastebin.com/mAhxUVDC</a></p>