Running a specific code once at 1st run Android -
i want run code once application run 1st time after installation. never again how it
following code here how trying
protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); securityprefs.setautosavepattern(this, true); string settingstag = "appnamesettings"; sharedpreferences prefs = getsharedpreferences(settingstag, 0); boolean run = prefs.getboolean("run", false); if (run == false) { run = true; intent intent = new intent(lockpatternactivity.action_create_pattern, null, this, lockpatternactivity.class); startactivityforresult(intent, req_create_pattern); } else { intent intent1 = new intent(lockpatternactivity.action_compare_pattern,null,this,lockpatternactivity.class); startactivityforresult(intent1, req_enter_pattern); } }
so problem facing?
string settingstag = "appnamesettings"; sharedpreferences prefs = getsharedpreferences(settingstag, 0); boolean run = prefs.getboolean("run", false);
your code should work if after running first time have updated shared preference , stored true "run".
Comments
Post a Comment