java - Android application crashes on Volley JsonObject POST request -


i'm trying write splash screen attempts authenticate users' credentials if exist in sharedpreference, application shuts down without warning on line request added requestqueue. should resolve issue?

file preffile = new file("/data/data/"+getpackagename()+"/shared_prefs/"+getpackagename()             +"_preferences.xml");     system.out.println(preffile.tostring());     if(preffile.exists()) {         system.out.println("found preference file");        final sharedpreferences pref = new securepreferences(getapplicationcontext());          map<string, string> authparams = new hashmap<string, string>();         authparams.put("key", pref.getstring("key",""));         authparams.put("action", "validate");          system.out.println("now authenticating");         jsonobjectrequest authrequest = new jsonobjectrequest(request.method.post, auth_url,                 new jsonobject(authparams), new response.listener<jsonobject>() {             @override             public void onresponse(jsonobject response) {               /*  intent intent = new intent(launchscreen.this, baseactivity.class);                 startactivity(intent); */             }         }, new response.errorlistener() {             @override             public void onerrorresponse(volleyerror error) {                 networkresponse response = error.networkresponse;                 system.out.println(response.tostring());                 system.out.println(error.getmessage());                 error.printstacktrace();             }         }) {             @override             public map<string, string> getheaders() throws authfailureerror {                 map<string, string> headers = new hashmap<string, string>();                 headers.put("accept", "application/json");                 headers.put("authorization", "token " + pref.getstring("key",""));                  return headers;             }              @override             public string getbodycontenttype() {                 return "application/json";             }         };         system.out.println("adding queue");         volley.newrequestqueue(getapplicationcontext()).add(authrequest);     } else {         system.out.println("opening login activity");         intent intent = new intent(this, loginactivity.class);         startactivity(intent);     } 

you try in onerrorresponse method:

volleylog.e(error.getmessage()); 

then, check logs in android adb monitor


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -