lisovaccaro
lisovaccaro

Reputation: 34016

Choose which activity to start on app initializing?

It was hard to summarize the problem in the title but it's really not very complicated.

My problem is this: After installing an app you see an "Open app" button on the play store which initiates your app similarly to when you click run on Eclipse. When you do either of these things the first launcher activity found in the manifest is brought to started.

For example if this were 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 was clicked SettingsActivity would be started since the first activity isn't a launcher app.

My problem is that the first time users open my app I want them to see the launcher. how do I make sure .launcher is started when my application is opened?

Upvotes: 6

Views: 298

Answers (2)

Anis BEN NSIR
Anis BEN NSIR

Reputation: 2555

you have to delete intent filter from SettingsActivity

To resolve redirecting user there is many solutions: 1- You can use two different method, Add a SplashScreen activity and add you Logic to determine next Activity. 2- Add non visible UI Activity as You main Activity, for more detail see this tutorial: TranscludeActivity

3- Make luncher you main Activity, after that, within the onCreate method, test if Settings existe, if not start SettingsActivity and call to finish();

Upvotes: 0

class stacker
class stacker

Reputation: 5347

You should not distinguish this based on the Intent level. Instead, have a SharedPreferences file for your app, in which you write an integer representing the version if it does not yet exist resp. indicates an older version. Then, based on that mechanism, you implement your "first time install" and/or "first run after update" logic.

Upvotes: 2

Related Questions