با سلام
متاسفانه چند روزه با مشکل عجیبی هنگام استفاده از کتابخونه Vollay برخوردم.
بنده وقتی برنامه رو با WIFI اجرا میکنم همه چی اوکی کار میکنه اما وقتی از دیتای موبایل استفاده میکنم با خطای زیر مواجه میشم :
om.android.volley.TimeoutError
کمی سرچ گوگل منو با این رشته کد مواجه کرد اما متاسفانه تغییر زمان درخواست هم چاره مار نشد :
MyStringRequest.setRetryPolicy(policy);
با رشته کد زیر دنبال خطا گشتم :
@Override
public void onErrorResponse(VolleyError error) {
//This code is executed if there is an error.
/*Toast.makeText(getApplicationContext(),"مشکل� � در دریافت اطلاعات وجود دارد",Toast.LENGTH_LONG).show();*/
String message = null;
if (error instanceof NetworkError) {
message = "Caot coect to Internet...Please check your coection!";
} else if (error instanceof ServerError) {
message = "The server could not be found. Please try again after some time!!";
} else if (error instanceof AuthFailureError) {
message = "Caot coect to Internet...Please check your coection!";
} else if (error instanceof ParseError) {
message = "Parsing error! Please try again after some time!!";
} else if (error instanceof NoCoectionError) {
message = "Caot coect to Internet...Please check your coection2!";
} else if (error instanceof TimeoutError) {
message = "Coection TimeOut! Please check your internet coection3.";
}
Log.e("message=>>>>>>"," "+message);
}
که خروجی خطا رو به صورت زیر نشون میده :
07-21 15:07:37.133 10481-10481/com.a.app E/error=>>>>>>: com.android.volley.NoCoectionError: java.io.EOFException
07-21 15:07:37.133 10481-10481/com.a.app E/message=>>>>>>: Caot coect to Internet...Please check your coection!
07-21 15:07:37.133 10481-10481/com.a.app E/error=>>>>>>: com.android.volley.NoCoectionError: java.io.EOFException
07-21 15:07:37.194 10481-10481/com.a.app E/message=>>>>>>: Caot coect to Internet...Please check your coection!
07-21 15:07:37.195 10481-10481/com.a.app E/error=>>>>>>: com.android.volley.NoCoectionError: java.io.EOFException
07-21 15:07:37.195 10481-10481/com.a.app E/message=>>>>>>: Caot coect to Internet...Please check your coection!
مطمینم ک اینترنت داره گوشی ؛ کلافم کرده ، نمیدونم دیگه چیکار میشه کرد .
ضمیمه، با این تیکه کدها هم اینترنت رو چک میکنم؛ (خروجی Log هم true هستش)
public static boolean isOnline(Context context) {
try {
boolean a=isOnline_Mob(context);
boolean b=wifiState(context);
if(a || b){
return isCoectingToInternet(context);
}else{
return false;
}
}catch (Exception e) {
Log.wtf("Exception e=>", " "+e);
return false;
}
}
و
public static boolean isOnline_Mob(Context context) {
CoectivityManager cm = (CoectivityManager) context.getSystemService(Context.CONNECTIVITY_SERV ICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
return (netInfo != null && netInfo.isCoected());
}
و
}
Log.e("false=>", "false");
return false;
}
برچسب:
نویسنده: محمد رضا جوادیان