java - application crashing however logcat shows no Caused by: -
my application crashing while submitting on register page logcat not showing caused (i think might php server app making crash im unsure)
if there code link me show issue please comment , try , help.
04-24 10:36:43.910: e/androidruntime(8764): fatal exception: main 04-24 10:36:43.910: e/androidruntime(8764): java.lang.nullpointerexception 04-24 10:36:43.910: e/androidruntime(8764): @ com.loggedin.login$processlogin.onpostexecute(login.java:173) 04-24 10:36:43.910: e/androidruntime(8764): @ com.loggedin.login$processlogin.onpostexecute(login.java:1) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.asynctask.finish(asynctask.java:631) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.asynctask.access$600(asynctask.java:177) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.asynctask$internalhandler.handlemessage(asynctask.java:644) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.handler.dispatchmessage(handler.java:99) 04-24 10:36:43.910: e/androidruntime(8764): @ android.os.looper.loop(looper.java:176) 04-24 10:36:43.910: e/androidruntime(8764): @ android.app.activitythread.main(activitythread.java:5419) 04-24 10:36:43.910: e/androidruntime(8764): @ java.lang.reflect.method.invokenative(native method) 04-24 10:36:43.910: e/androidruntime(8764): @ java.lang.reflect.method.invoke(method.java:525) 04-24 10:36:43.910: e/androidruntime(8764): @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1046) 04-24 10:36:43.910: e/androidruntime(8764): @ com.android.internal.os.zygoteinit.main(zygoteinit.java:862) 04-24 10:36:43.910: e/androidruntime(8764): @ dalvik.system.nativestart.main(native method)
login page code
import android.app.progressdialog; import android.content.context; import android.net.connectivitymanager; import android.net.networkinfo; import android.os.asynctask; import org.json.jsonexception; import org.json.jsonobject; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.view; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.toast; import com.loggedin.internal.databasehandler; import com.loggedin.internal.userfunctions; import java.io.ioexception; import java.net.httpurlconnection; import java.net.malformedurlexception; import java.net.url; public class login extends activity { button btnlogin; button registerbtn1; button passwordresetbtn; edittext inputusername; edittext inputpassword; private textview loginerrormsg; /** * called when activity first created. */ private static string key_success = "success"; private static string key_uid = "id"; private static string key_username = "username"; private static string key_firstname = "firstname"; private static string key_lastname = "lastname"; private static string key_email = "email"; private static string key_dob = "dob"; private static string key_created_at = "created_at"; @override public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_login); inputusername = (edittext) findviewbyid(r.id.username); inputpassword = (edittext) findviewbyid(r.id.password); registerbtn1 = (button) findviewbyid(r.id.registerbtn1); btnlogin = (button) findviewbyid(r.id.loginbtn1); passwordresetbtn = (button)findviewbyid(r.id.passwordresetbtn); loginerrormsg = (textview) findviewbyid(r.id.loginerrormsg); passwordresetbtn.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { intent myintent = new intent(view.getcontext(), passwordreset.class); startactivityforresult(myintent, 0); finish(); }}); registerbtn1.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { intent myintent = new intent(view.getcontext(), register.class); startactivityforresult(myintent, 0); finish(); }}); /** * login button click event * toast set alert when email , password field empty **/ btnlogin.setonclicklistener(new view.onclicklistener() { public void onclick(view view) { if ( ( !inputusername.gettext().tostring().equals("")) && ( !inputpassword.gettext().tostring().equals("")) ) { internetasync(view); } else if ( ( !inputusername.gettext().tostring().equals("")) ) { toast.maketext(getapplicationcontext(), "password field empty", toast.length_short).show(); } else if ( ( !inputpassword.gettext().tostring().equals("")) ) { toast.maketext(getapplicationcontext(), "username field empty", toast.length_short).show(); } else { toast.maketext(getapplicationcontext(), "username , password field empty", toast.length_short).show(); } } }); } /** * async task check whether internet connection working. **/ private class internetcheck extends asynctask <string, string, boolean> { private progressdialog ndialog; @override protected void onpreexecute(){ super.onpreexecute(); ndialog = new progressdialog(login.this); ndialog.settitle("checking network"); ndialog.setmessage("loading.."); ndialog.setindeterminate(false); ndialog.setcancelable(true); ndialog.show(); } @override protected boolean doinbackground(string... args){ /** * gets current device state , checks working internet connection trying google. **/ connectivitymanager cm = (connectivitymanager) getsystemservice(context.connectivity_service); networkinfo netinfo = cm.getactivenetworkinfo(); if (netinfo != null && netinfo.isconnected()) { try { url url = new url("http://www.google.com"); httpurlconnection urlc = (httpurlconnection) url.openconnection(); urlc.setconnecttimeout(3000); urlc.connect(); if (urlc.getresponsecode() == 200) { return true; } } catch (malformedurlexception e1) { // todo auto-generated catch block e1.printstacktrace(); } catch (ioexception e) { // todo auto-generated catch block e.printstacktrace(); } } return false; } @override protected void onpostexecute(boolean th){ if(th == true){ ndialog.dismiss(); new processlogin().execute(); } else{ ndialog.dismiss(); loginerrormsg.settext("error in network connection"); } } } /** * async task , send data sql database through json respone. **/ private class processlogin extends asynctask <string, string, jsonobject> { private progressdialog pdialog; string username, password; @override protected void onpreexecute() { super.onpreexecute(); inputusername = (edittext) findviewbyid(r.id.username); inputpassword = (edittext) findviewbyid(r.id.password); username = inputusername.gettext().tostring(); password = inputpassword.gettext().tostring(); pdialog = new progressdialog(login.this); pdialog.settitle("contacting servers"); pdialog.setmessage("logging in ..."); pdialog.setindeterminate(false); pdialog.setcancelable(true); pdialog.show(); } @override protected jsonobject doinbackground(string... args) { userfunctions userfunction = new userfunctions(); jsonobject json = userfunction.loginuser(username, password); return json; } @override protected void onpostexecute(jsonobject json) { try { if (json.getstring(key_success) != null) { string res = json.getstring(key_success); if(integer.parseint(res) == 1){ pdialog.setmessage("loading user space"); pdialog.settitle("getting data"); databasehandler db = new databasehandler(getapplicationcontext()); jsonobject json_user = json.getjsonobject("user"); /** * clear previous data in sqlite database. **/ userfunctions logout = new userfunctions(); logout.logoutuser(getapplicationcontext()); db.adduser(json_user.getstring(key_firstname),json_user.getstring(key_lastname),json_user.getstring(key_email),json_user.getstring(key_dob),json_user.getstring(key_username),json_user.getstring(key_uid)); /** *if json array details stored in sqlite launches user panel. **/ intent upanel = new intent(getapplicationcontext(), main.class); upanel.addflags(intent.flag_activity_clear_top); pdialog.dismiss(); startactivity(upanel); /** * close login screen **/ finish(); }else{ pdialog.dismiss(); loginerrormsg.settext("incorrect username/password"); } } } catch (jsonexception e) { e.printstacktrace(); } } }
verify if variable null in onpostexecute method on onpostexecute
Comments
Post a Comment