title: FCM onTokenRefresh() Can't create handler inside thread that has not called Looper.prepare()
body: <p>I have an app which is basically get the notification from my own server using Firebase Cloud Messaging service whenever the API is called, strangely when i install it through Android studio RUN menu, which is install the app directly to my device the APP is working fine, but when i take the app-debug from my project directory and install it manually, it gives me the error</p>
  
  <pre><code>Can't create handler inside thread that has not called Looper.prepare()
  </code></pre>
  
  <p>the error points out to my method that sending data to my database using volley library inside <code>onTokenRefresh()</code> Method.</p>
  
  <p>i am putting that methods inisde a serveice that extends FirebaseInstanceIdService.</p>
  
  <p>this is the complete error message</p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: pool-3-thread-1
     Process: proizzy.com.qrcodeproizzyadm, PID: 5704
     java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
     at android.os.Handler.&lt;init&gt;(Handler.java:200)
     at android.os.Handler.&lt;init&gt;(Handler.java:114)
     at android.widget.Toast$TN.&lt;init&gt;(Toast.java:645)
     at android.widget.Toast.&lt;init&gt;(Toast.java:137)
     at android.widget.Toast.makeText(Toast.java:440)
     at proizzy.com.qrcodeproizzyadm.Notification.FirebaseInstanceIDService.onTokenRefresh(FirebaseInstanceIDService.java:25)
     at com.google.firebase.iid.FirebaseInstanceIdService.zza(Unknown Source)
     at com.google.firebase.iid.FirebaseInstanceIdService.zzm(Unknown Source)
     at com.google.firebase.iid.zzb$2.run(Unknown Source)
     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
     at java.lang.Thread.run(Thread.java:818)
  </code></pre>
  
  <p>i dont have any clue what went wrong with my code.</p>
  
  <p>this is my complete code of the service class</p>
  
  <pre><code>public class FirebaseInstanceIDService extends FirebaseInstanceIdService {
  
  @Override
  public void onTokenRefresh() {
      final String token = FirebaseInstanceId.getInstance().getToken();
      Log.v("tok", token);
  
      String tokUrl = "someurl.php";
      JsonObjectRequest regToken = new JsonObjectRequest(Request.Method.POST, tokUrl, null,
              new Response.Listener&lt;JSONObject&gt;() {
                  @Override
                  public void onResponse(JSONObject response) {
                      Log.v("success", response.toString());
                  }
              }, new Response.ErrorListener() {
          @Override
          public void onErrorResponse(VolleyError error) {
              Log.v("errorvolley", error.getMessage());
          }
      }){
          @Override
          protected Map&lt;String, String&gt; getParams() {
              Map&lt;String, String&gt; params = new HashMap&lt;&gt;();
              params.put("token", token);
              return params;
          }
      };
  
      RequestQueue regQueue = Volley.newRequestQueue(getApplicationContext());
      regQueue.add(regToken);
  
  }
  </code></pre>