android intent - Cannot go to the next activity -
i creating application input height , weight, compute bmi click next button go class , display bmi result on fragment within class.i want know why stops after clicking button. here code:
package com.example.hcon; import android.app.activity; import android.content.intent; import android.os.bundle; import android.view.menu; import android.view.view; import android.view.view.onclicklistener; import android.widget.button; import android.widget.edittext; import android.widget.textview; import android.widget.toast; public class firstactivity extends activity { button button1; edittext et_name; edittext et_height; edittext et_weight; double ht = 0; double wt = 0; textview bmiout; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_first); et_name = (edittext) findviewbyid(r.id.et_name); button1 = (button) findviewbyid(r.id.button1); button1.setonclicklistener(new onclicklistener() { public void onclick(view v) { et_height = (edittext) findviewbyid(r.id.et_height); et_weight = (edittext) findviewbyid(r.id.et_weight); ht = double.parsedouble(et_height.gettext().tostring()); wt = double.parsedouble(et_weight.gettext().tostring()); double bmi = wt / (ht * ht); intent = new intent(firstactivity.this, secactivity.class); a.putextra(out, out); toast.maketext(firstactivity.this, "welcome " + et_name.gettext().tostring(), toast.length_long).show(); startactivity(new intent(firstactivity.this, secactivity.class)); } }); } @override public boolean oncreateoptionsmenu(menu menu) { // inflate menu; adds items action bar if present. getmenuinflater().inflate(r.menu.first, menu); return true; } }
secactivity.class activity containing fragment output should displayed.
use getapplicationcontext
, pass context in intent
. , pass a
in startactivity
intent = new intent(getapplicationcontext(), secactivity.class); a.putextra(out, out); //your toast startactivity(a));