android - How to run an activity only once like Splash screen -
in app, run splash screen once @ first run problem placed in manifest
line: android:nohistory="true"
works great if press button , exits app note app still in background running, , when press app icon goes again splash screen registration page. wanted redirected registration page directly when reopen application.
how do this? ahead suggestions.
this how achieved it!hope helps!
import android.app.activity; import android.content.intent; import android.content.sharedpreferences; import android.os.bundle; public class check extends activity{ @override protected void oncreate(bundle savedinstancestate) { // todo auto-generated method stub super.oncreate(savedinstancestate); sharedpreferences settings=getsharedpreferences("prefs",0); boolean firstrun=settings.getboolean("firstrun",false); if(firstrun==false)//if running first time //splash load first time { sharedpreferences.editor editor=settings.edit(); editor.putboolean("firstrun",true); editor.commit(); intent i=new intent(check.this,splash.class); startactivity(i); finish(); } else { intent a=new intent(check.this,main.class); startactivity(a); finish(); } } }
Comments
Post a Comment