1
即時通訊使用android排球庫爲我的應用程序,當即時通訊使用WiFi其工作,但它似乎有問題與蜂窩數據連接。在一些手機(LG G3安卓6,魅族安卓5.1)與蜂窩數據它不工作,並給出超時錯誤,但在(HTC渴望816安卓4.4,LG G3的Android 5.0)再次其工作android排球庫給蜂窩數據連接超時錯誤
是什麼問題?
的logcat:
D/ERROR: error => com.android.volley.TimeoutError
代碼:
showLoadingDialog();
StringRequest postRequest = new StringRequest(Request.Method.POST, url,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
try {
JSONObject jobj = new JSONObject(response);
JSONObject jobjHRM = jobj.getJSONObject("HRM");
int status = jobjHRM.getInt("StatusCode");
if (status == 200) {
if (jobj.getJSONObject("Data").getBoolean("result") == true) {
login_info_editor.putInt("id", jobj.getJSONObject("Data").getInt("id"));
login_info_editor.putString("username", txtlayoutid.getEditText().getText().toString());
login_info_editor.putString("password", txtlayoutpass.getEditText().getText().toString());
login_info_editor.putBoolean("loged", true);
login_info_editor.commit();
checkversion();
} else {
login_info_editor.clear();
login_info_editor.commit();
txtlayoutid.requestFocus();
Toast.makeText(getApplicationContext(), "نام کاربری یا کلمه ی عبور اشتباه است", Toast.LENGTH_LONG).show();
txtlayoutid.startAnimation(shake);
txtlayoutpass.startAnimation(shake);
hideLoadingDialog();
}
} else {
Toast.makeText(getApplicationContext(), "ارور " + status, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
}
}
},
new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
hideLoadingDialog();
Log.d("ERROR", "error => " + error.toString());
}
}
) {
@Override
protected Map<String, String> getParams() throws AuthFailureError {
Map<String, String> params = new HashMap<String, String>();
params.put(xxxxxx);
params.put(xxxxxx);
params.put(xxxxxx);
return params;
}
@Override
public String getBodyContentType() {
return "application/x-www-form-urlencoded; charset=UTF-8";
}
};
AppController.getInstance().addToRequestQueue(postRequest);
查看更新.. – Msp
因爲當時'postRequest'是空嘗試使用'socketTimeout' – Msp
不同的值。在AppController.getInstance()。addToRequestQueue(postRequest)' – Msp