Json を介して Android アプリケーションをサーバーに接続したいと考えています。このリンクhttp://developer.github.com/v3/を参照していた github 経由で接続することは可能 ですか?
2 に答える
0
Volley、最新の Google AsyncHttpClient Api [このリンクをチェック] またはここを使用することもできます。あなたがやりたいことに対して、はるかにシンプルで使いやすいと思います。例えば:
private RequestQueue reqQueue = Volley.newRequestQueue(this);
private JsonObjectRequest jsObjRequest;
public void connectViaVolley(){
String servURL="https://api.github.com/repos/mojombo/jekyll/issues?state=closed"; //this URL is what is on GitHub already, so you can test with it
jsObjRequest = new JsonObjectRequest(Request.Method.GET, servURL, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
//Handle any non-error response and parse the JSONobject
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
//handle any errors here [no need for exceptions as Volley does this already]
}
});
//actual network connection/request
reqQueue.add(jsObjRequest);
}
于 2013-10-31T06:21:25.587 に答える