android - Starting new Activity in OnCreate -
i got android app based on 2 activities. main activity input field , button user information. when user press button barcodescanner (zxing) start.
every thing works perfect. know try check in oncreate if user information known. if true -> start barcodescanner. looks barcodescanner activity starts twice, because: pressing button once: annother barcodescanner wil active. pressing button twice: main activty active.
this check inside oncreate:
if(pref.length() == 6){ startactivityforresult(intent, 0); }
and function called when clicking button:
public void onclick(view view) { switch (view.getid()) { case r.id.button1: final edittext edit = (edittext) findviewbyid(r.id.panelid); if(edit.gettext().tostring().length() == 6){ string temp = edit.gettext().tostring(); log.e("click", temp); editor e = this.getpreferences(context.mode_private).edit(); e.putstring("panelid", temp); e.commit(); startactivityforresult(intent, 0); } else { toast.maketext(this, "ongeldige invoer (6 cijfer id)", toast.length_long).show(); } break; } }
what do wrong?
your trouble seems more how managing lifecycle of activity. if post activity's oncreate() method's code, might able see better you're trying accomplish , suggest solution accordingly.
Comments
Post a Comment