Choose what activity to start when initializing the application?

It was difficult to summarize the problem in the title, but it really is not very difficult.

My problem is this: after installing the application, you will see the "Open Application" button in the playback store, which launches your application in the same way when you click "Run on Eclipse". When you do one of these actions, the first launch activity that is detected in the manifest starts first.

For example, if this was my manifest:

<!-- Home screen replacemnt --> <activity android:name=".launcher" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.HOME" /> <category android:name="android.intent.category.DEFAULT" /> </intent-filter> </activity> <!-- Launcher Application --> <activity android:name=".SettingsActivity" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> 

When open SettingsActivity been pressed, it will be launched, since the first action is not a launch application.

My problem is that the first time users open my application, I want them to see the launcher. How can I make sure .launcher running when my application is open?

+6
source share
2 answers

You should not distinguish this from the Intent level. Instead, you have a SharedPreferences file for your application in which you write an integer representing the version if it does not already exist or. indicates an older version. Then, based on this mechanism, you implement the logic “first time setting” and / or “first start after update”.

+2
source

you need to remove the intent filter from SettingsActivity

There are many solutions to allow user redirection: 1- You can use two different methods: add SplashScreen activity and add logic to determine the next activity. 2- Add invisible user interface activity as the main operation, see this tutorial for more details: TranscludeActivity

3. Make luncher you main. Actions, after that, in the onCreate method, check if the settings exist, if you do not run SettingsActivity and call the end ();

0
source

All Articles