문제

How can I set an Activity that will be the Launch Activity just one time ( when the user sign up )? e.g. I have a Settings Activity and a NewsFeed Activity. The first time I want to lanch the app with the Settings Activity and, after the user fill the options, he goes to the NewsFeed Activity. The second time, after the settings filled, I want to launch the app with NewsFeed Activity.

I google it but could not find any detailed explanation or tutorial.

도움이 되었습니까?

해결책

Its very simple.

You can use preferences to store if this first time then show Settings Activity else always show NewsFeed Activity.

Below is the sample code to use Preferences

SharedPreferences prefs = this.getSharedPreferences("MyAppPrefs", MODE_WORLD_0);
boolean settingsFilled = prefs.getBoolean("SettingsFilled", false);

if(!settingsFilled)
{
    //SHOW SETTINGS ACTIVITY

    SharedPreferences prefs = this.getSharedPreferences("MyAppPrefs", 0);
    Editor editor = prefs.edit();
    editor.putBoolean("SettingsFilled", true);
    editor.commit();
}

Use the above code in your NewsFeed Activity.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top