私のアンドロイドアプリのURLからデータを取得しようとしています。私はGet/Postリクエストにvolleyライブラリを使用しています。以下は、URLのコンテンツを取得するために私のコードです:JSONの解析中にJSONexceptionをスローすることができません
JsonObjectRequest jsonObjectRequest = new JsonObjectRequest( Request.Method.GET, R.string.login, null,
new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
Intent intent = new Intent(LoginActivity.this, HomeActivity.class);
startActivity(intent);
finish();
} catch (JSONException e) {
e.printStackTrace();
Log.e("ex","Exception Caught! "+e);
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
}
});
RequestQueue requestQueue = Volley.newRequestQueue(this);
requestQueue.add(jsonObjectRequest);
しかし、私はJSONExceptionに次のエラーを取得しています:
例外org.json.JSONexceptionは、tryブロック
対応でスローされることはありません誰か助けてくれますか?
よろしく
パンカジ
正しいではなく、少し良くあなたの答えをフォーマットすることを扱います。 – basic
そうですね。投稿後に書式を見た。 :D – Rohit5k2