title: android OkHttpClient Requesting Error
body: <p>I am trying to store some data in mysql database using my android app. I am using okhttp3 to send request , but an error appears to me at this line:</p>
  
  <pre><code>client.newCall(request).execute();
  </code></pre>
  
  <p>I tried it on local machine and online but it gives me the same error here is the code ,</p>
  
  <pre><code>public class MainActivity extends AppCompatActivity {
  
      String token1;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
          System.out.println("MainActivity is :" + FirebaseInstanceId.getInstance().getToken());
          FirebaseMessaging.getInstance().subscribeToTopic("test");
          FirebaseInstanceId.getInstance().getToken();
          token1=FirebaseInstanceId.getInstance().getToken();
      }
  
      public void clicking(View view) {
  
          OkHttpClient client = new OkHttpClient();
          RequestBody body = new FormBody.Builder()
                  .add("Token",token1)
                  .build();
  
          okhttp3.Request request = new okhttp3.Request.Builder()
                  .url("http://saleh923.byethost8.com/hii.html")
                  .post(body)
                  .build();
  
          try {
              client.newCall(request).execute();
          } catch (IOException e) {
  
              e.printStackTrace();
          }
      }
  }
  </code></pre>
  
  <p>and here is the log:</p>
  
  <pre><code> com.example.user.firebasenot E/AndroidRuntime: FATAL EXCEPTION: main
      Process: com.example.user.firebasenot, PID: 3280
      java.lang.IllegalStateException: Could not execute method for android:onClick
          at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
          at android.view.View.performClick(View.java:5198)
          at android.view.View$PerformClick.run(View.java:21147)
          at android.os.Handler.handleCallback(Handler.java:739)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:148)
          at android.app.ActivityThread.main(ActivityThread.java:5417)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
       Caused by: java.lang.reflect.InvocationTargetException
          at java.lang.reflect.Method.invoke(Native Method)
          at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
          at android.view.View.performClick(View.java:5198) 
          at android.view.View$PerformClick.run(View.java:21147) 
          at android.os.Handler.handleCallback(Handler.java:739) 
          at android.os.Handler.dispatchMessage(Handler.java:95) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5417) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
       Caused by: android.os.NetworkOnMainThreadException
          at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1273)
          at java.net.InetAddress.lookupHostByName(InetAddress.java:431)
          at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
          at java.net.InetAddress.getAllByName(InetAddress.java:215)
          at okhttp3.Dns$1.lookup(Dns.java:39)
          at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.java:172)
          at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.java:138)
          at okhttp3.internal.connection.RouteSelector.next(RouteSelector.java:80)
          at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:178)
          at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:129)
          at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:98)
          at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
          at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:109)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
          at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
          at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:124)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:92)
          at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:67)
          at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:170)
          at okhttp3.RealCall.execute(RealCall.java:60)
          at com.example.user.firebasenot.MainActivity.clicking(MainActivity.java:54)
          at java.lang.reflect.Method.invoke(Native Method) 
          at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
          at android.view.View.performClick(View.java:5198) 
          at android.view.View$PerformClick.run(View.java:21147) 
          at android.os.Handler.handleCallback(Handler.java:739) 
          at android.os.Handler.dispatchMessage(Handler.java:95) 
          at android.os.Looper.loop(Looper.java:148) 
          at android.app.ActivityThread.main(ActivityThread.java:5417) 
          at java.lang.reflect.Method.invoke(Native Method) 
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) 
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) 
  </code></pre>