android - How to start app from first when home button is clicked -
in application when click home button , when again when open app should come first.i having splash screen first activity.when open app,the app should start splash screen.
@override public void onattachedtowindow() { super.onattachedtowindow(); this.getwindow().settype(windowmanager.layoutparams.type_keyguard); } @override public boolean onkeydown(int keycode, keyevent event) { if(keycode == keyevent.keycode_home) { log.i("home button","clicked"); onpause(); } return false; } protected void onpause() { super.onpause(); intent i=new intent(h2.this,homeexampleactivity.class); startactivity(i); // start first activity }
i tried in way overriding on pause method not working.please me how solve issue
you can try this:
boolean hasgone = false; @override void onresume() { super.onresume(); if(hasgone){ intent intent = new intent(h2.this, homeexampleactivity.class); intent.setflags(intent.flag_activity_clear_top); startactivity(intent); } } @override void onpause() { super.onpause(); hasgone = true; }
Comments
Post a Comment