私はアプリのマニフェストにandroid.permission.INTERNETあなたの権限を追加し
のGradle
compile 'com.android.volley:volley:1.0.0'
を通して、あなたのプロジェクトにバレーボールを追加
Volley
を使用することをお勧めします。コードは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);
から取られ
それは非常に良い答えかもしれませんが、私はそれを得るいけません。私の問題:どこにPOST https://www.googleapis.com/games/v1management/applications/applicationId/players/hidden/playerIdを入れるのですか?私はコードや外部からこれを使用していますか? – Phil
こんにちは、URLをString URLに置くことができます(コメントに//あなたのWeb呼び出しを設定します)。そして、stringRequestでRequest.Method.POSTを使用します。 つまり、個々のGETリクエストとPOSTリクエストに対して別々のStringRequestを作成できます。それに応じて、必要な他のパラメータを追加することもできます。 –