android - Force main activity to show every time app is loaded -
i want main activity show every time after home screen pressed , app opened again.
my layout is:
main screen --> menu page --> sub menu
i want able use button go sub menu menu page. however, regardless of page on when home screen pressed want show main screen when app reopened. have tried onfinish() in java class menupage. causes return button close app because previous activity finished. have researched how can detect if home button pressed finish activity way seems that's not option. know way around this?
to control presses, can direct each activity or fragment go wherever on press overriding backpress event.
@override public void onbackpressed() { // }
to handle backpress , state fragments, advisable manage stack.
i use custom home button on apps when want user able go straight main activity.
public void gohome() { startactivity(new intent(this, mainactivity.class)); }
edit
this part of original answer, not addressing op asking. left here in case helps browsers may have misinterpreted question , looking this.
you need set main activity launcher activity app , use boot_completed , default. means user have choose default option each time press home key, until either set app or default device homescreen 'always' default.
<activity android:name=".main"> <intent-filter> <action android:name="android.intent.action.boot_completed" /> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.home" /> <category android:name="android.intent.category.default" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>
Comments
Post a Comment