StringRequest strReq = new StringRequest(Request.Method.POST,
Config.URL_REGISTER, new Response.Listener<String>() {
@Override
public void onResponse(String response) {
Log.d("Response", "Register Response: " + response.toString());
try {
JSONObject jsonObject = new JSONObject(response);
if (jsonObject.getString("result").equals("success")) {
Toast.makeText(getApplicationContext(),jsonObject.getString("message"), Toast.LENGTH_LONG).show();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
editor.putString("id","");
editor.putString("email", email);
editor.putString("user_name", userName);
editor.putString("user_pass", userPass);
editor.putString("confirm_pass", confirmPassword);
Intent intent = new Intent(
RegisterActivity.this,
MainActivity.class);
startActivity(intent);
finish();
}
logcatなっているの:$ 1 がに変換することができませんorg.json.JSONObjectタイプのNULL値:JSONObjectがnull応答に
登録応答:ヌル
がorg.json.JSONExceptionをJSONObject
は、URLとレスポンスを共有しています。 –
あなたのjsonを投稿してください –
あなたの応答は 'null 'であり、JSONを解析する前にそれを処理する必要があるからです。だからあなたはこのコードを置くことでそれを扱うことができます 'if(response!= null)try {} code'の前にまだ動作していなければ' if(!response.equals( "null")) ' – Sodiq