Search code examples
androidhttprequestdeveloper-console

Android Developer Console How to send a HTTP Request?


I have a little app with a leaderboard and i want to hide players with fake scores. I read about it at https://developers.google.com/games/services/management/api/players/hide#request

The Problem is, that i have no idea from http Requests and that things. So how do i send a HTTP Request? Is there a Terminal or something in the Developer Console from Google, where i put my command in? Or what do i need to do, to send an Request like this?


Solution

  • I recommend that you use Volley

    Add Volley to your project through Gradle

    compile 'com.android.volley:volley:1.0.0'
    

    Add the android.permission.INTERNET permission to your app's manifest.

    The code is taken from 1

     // Instantiate the RequestQueue.
     RequestQueue queue = Volley.newRequestQueue(this);
     String url ="http://www.google.com"; //set your web call here
    
     // Request a string response from the provided URL.
     StringRequest stringRequest = new StringRequest(Request.Method.GET, url,
            new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
           //handle success 
        }
           }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
           //handle error
        }
    });
    
    // Add the request to the RequestQueue.
    queue.add(stringRequest);