Android Activity not Responding -
i have 3 activities in app , when user press next button, next activity shown user, works fine except when reaches last activity i.e. when user presses next on 2nd last activity, error message shown app has stopped working , there no error in logcat, following .java file of final activity
package com.example.first; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.content.intent; import android.os.bundle; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.widget.textview; import android.os.build; public class finalactivity extends actionbaractivity { textview name,address,phone,email,dob,matg,mati,interg,interi,graddeg,gradi,cgpa,skills; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_final); name=(textview)findviewbyid(r.id.fname); address=(textview)findviewbyid(r.id.faddress); phone=(textview)findviewbyid(r.id.fphone); email=(textview)findviewbyid(r.id.femail); dob=(textview)findviewbyid(r.id.fdob); matg=(textview)findviewbyid(r.id.matricgrade); mati=(textview)findviewbyid(r.id.matricinst); interg=(textview)findviewbyid(r.id.intergrade); interi=(textview)findviewbyid(r.id.interinst); graddeg=(textview)findviewbyid(r.id.graddegree); cgpa=(textview)findviewbyid(r.id.gradcgpa); skills=(textview)findviewbyid(r.id.iskills); intent in=getintent(); userbo bo=new userbo(); bo.name=in.getstringextra("name"); bo.address=in.getstringextra("address"); bo.email=in.getstringextra("email"); bo.phone=in.getstringextra("phone"); bo.dob=in.getstringextra("dob"); bo.mg=in.getstringextra("mgrade"); bo.mi=in.getstringextra("minst"); bo.ig=in.getstringextra("igrade"); bo.ii=in.getstringextra("iinst"); bo.gg=in.getstringextra("gdeg"); bo.gi=in.getstringextra("ginst"); bo.cgpa=in.getstringextra("cgpa"); bo.skills=in.getstringextra("skills"); name.settext("name : "+bo.name); address.settext("address : "+bo.address); email.settext("email : "+bo.email); phone.settext("phone : "+bo.phone); dob.settext("dob : "+bo.dob); matg.settext("matric grade : "+bo.mg); mati.settext("institution : "+bo.mi); interg.settext("inter grade : "+bo.ig); interi.settext("institution : "+bo.ii); graddeg.settext("graduation degree : "+bo.gg); gradi.settext("institution : "+bo.gi); skills.settext("skills : "+bo.skills); } }
here xml file
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.example.first.finalactivity" tools:ignore="mergerootframe" > <scrollview android:layout_width="match_parent" android:layout_height="match_parent" > <linearlayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" > <textview android:id="@+id/fname" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/faddress" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/fphone" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/femail" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/fdob" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/matricgrade" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/matricinst" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/intergrade" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/interinst" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/graddegree" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/gradinst" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/gradcgpa" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/iskills" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> <textview android:id="@+id/hobbies" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="" /> </linearlayout> </scrollview> </framelayout>
here i'm calling final activity
package com.example.first; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.content.intent; import android.os.bundle; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.os.build; public class activity2 extends actionbaractivity { button next3; edittext s1,s2,s3,s4,s5; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_activity2); next3=(button)findviewbyid(r.id.next3); s1=(edittext)findviewbyid(r.id.sk1); s2=(edittext)findviewbyid(r.id.sk2); s3=(edittext)findviewbyid(r.id.sk3); s4=(edittext)findviewbyid(r.id.sk4); s5=(edittext)findviewbyid(r.id.sk5); next3.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub intent in=getintent(); userbo bo=new userbo(); bo.name=in.getstringextra("name"); bo.address=in.getstringextra("address"); bo.email=in.getstringextra("email"); bo.phone=in.getstringextra("phone"); bo.dob=in.getstringextra("dob"); bo.mg=in.getstringextra("mgrade"); bo.mi=in.getstringextra("minst"); bo.ig=in.getstringextra("igrade"); bo.ii=in.getstringextra("iinst"); bo.gg=in.getstringextra("gdeg"); bo.gi=in.getstringextra("ginst"); bo.cgpa=in.getstringextra("cgpa"); bo.skills+=s1.gettext().tostring()+","+s1.gettext().tostring()+","+s2.gettext().tostring()+","+s3.gettext().tostring()+","+s4.gettext().tostring()+","+s5.gettext().tostring(); intent i=new intent(getapplicationcontext(),finalactivity.class);//this,same system.out.println(bo.name); i.putextra("name", bo.name); i.putextra("address", bo.address); i.putextra("email", bo.email); i.putextra("phone", bo.phone); i.putextra("dob", bo.dob); i.putextra("mgrade", bo.mg); i.putextra("minst", bo.mi); i.putextra("igrade", bo.ig); i.putextra("iinst", bo.ii); i.putextra("gdeg", bo.gg); i.putextra("ginst", bo.gi); i.putextra("cgpa", bo.cgpa); i.putextra("skills", bo.skills); startactivity(i); } }); }
here activity1
package com.example.first; import android.support.v7.app.actionbaractivity; import android.support.v7.app.actionbar; import android.support.v4.app.fragment; import android.content.intent; import android.os.bundle; import android.view.layoutinflater; import android.view.menu; import android.view.menuitem; import android.view.view; import android.view.viewgroup; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.os.build; public class activity1 extends actionbaractivity { button next2; edittext matgrade,matinst,igrade,iinst,gdegree,ginst,gcgpa; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_activity1); next2=(button)findviewbyid(r.id.next2); matgrade=(edittext)findviewbyid(r.id.mgrade); matinst=(edittext)findviewbyid(r.id.minst); igrade=(edittext)findviewbyid(r.id.igrade); iinst=(edittext)findviewbyid(r.id.iinst); gdegree=(edittext)findviewbyid(r.id.gdegree); ginst=(edittext)findviewbyid(r.id.ginst); gcgpa=(edittext)findviewbyid(r.id.cgpa); next2.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub intent in=getintent(); userbo bo=new userbo(); bo.name=in.getstringextra("name"); bo.address=in.getstringextra("address"); bo.email=in.getstringextra("email"); bo.phone=in.getstringextra("phone"); bo.dob=in.getstringextra("dob"); bo.mg=matgrade.gettext().tostring(); bo.mi=matgrade.gettext().tostring(); bo.ig=igrade.gettext().tostring(); bo.ii=igrade.gettext().tostring(); bo.gg=gdegree.gettext().tostring(); bo.gi=gdegree.gettext().tostring(); bo.cgpa=gdegree.gettext().tostring(); intent i=new intent(getapplicationcontext(),activity2.class);//this,same i.putextra("name", bo.name); i.putextra("address", bo.address); i.putextra("email", bo.email); i.putextra("phone", bo.phone); i.putextra("dob", bo.dob); i.putextra("mgrade", bo.mg); i.putextra("minst", bo.mi); i.putextra("igrade", bo.ig); i.putextra("iinst", bo.ii); i.putextra("gdeg", bo.gg); i.putextra("ginst", bo.gi); i.putextra("cgpa", bo.cgpa); startactivity(i); } }); } }
here main activity
package com.example.first; import android.content.intent; import android.os.bundle; import android.support.v7.app.actionbaractivity; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; public class mainactivity extends actionbaractivity { button next1; edittext name,address,email,phone,date; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); next1=(button)findviewbyid(r.id.next1); name=(edittext)findviewbyid(r.id.name); address=(edittext)findviewbyid(r.id.address); email=(edittext)findviewbyid(r.id.email); phone=(edittext)findviewbyid(r.id.phone); date=(edittext)findviewbyid(r.id.date); next1.setonclicklistener(new onclicklistener() { @override public void onclick(view v) { // todo auto-generated method stub userbo bo=new userbo(); bo.name=name.gettext().tostring(); bo.address=address.gettext().tostring(); bo.email=email.gettext().tostring(); bo.phone=phone.gettext().tostring(); bo.dob=date.gettext().tostring(); intent i=new intent(getapplicationcontext(),activity1.class);//this,same i.putextra("name", bo.name); i.putextra("address", bo.address); i.putextra("email", bo.email); i.putextra("phone", bo.phone); i.putextra("dob", bo.dob); startactivity(i); } }); } }
please me find mistake
i think have null pointer exception. maybe 1 of controls missed in xml layout. example finding "next1" in code , using setonclicklistener
method while not defined in xml layout object null.
i recommend put content of oncreate
method in try-catch
, debug application.
Comments
Post a Comment