android - how to kill Activity permanetly After button click Using Shared prefrance -
Text after
public class MainActivity Activity {button extends btn1 @ override protected creature (bundle saved instenstate) {super. Nakrat (saved instenstate); Newpage = new intent (main activity. This, phonereavistian class); startActivity (newpage); btn1 = (button) findViewById (R.id.button1); Btn1.setOnClickListener (New OnClickListener () {@Override Public Zero onClick (see arg0) {// TODO auto-created method stub intents myintent = new intent (MainActivity.this, nextActvity.class); startActivities (zero);}}) ; }} This is my activity if I want to go from one activity to another in the activity I want to kill my activity means using permanently shared prefrances if open application then This should start second activity. Please help me I do not know how to kill activity using eaten prefrances
Here is the complete solution
// First of all, when you register, the user has set shared preferences in his registered class like // // pref editor shared prefs presentations; Shared References Editor prefsEditor; Prefs = PreferenceManager.getDefaultSharedPreferences (this); PrefsEditor = prefs.edit (); // Paste the code down peacefully when registration will be successful prefsEditor.putString ("Register", "Yes"); prefsEditor.commit (); // Now in your first activity you can check the shared value of the shared value to know about a shared business registered or shared; String register; Prefs = PreferenceManager.getDefaultSharedPreferences (this); Register = prefs.getString ("register", ""); // Now check the value of the shared pref and apply the condition such intent to this effect; If (register.equalsIgnoreCase ("yes")) {intent = new intent (this, next act.class); StartActivity; End(); } And {intent = new intent (this, register class); StartActivity; End(); }
Comments
Post a Comment