Frage

I'm a little confused on how I should start another activity than MainActivity when the application starts. What I've searched up so far is to move the intent-filter to the activity I want to start, but it's no good. What happens is that in the launcher on my device, the app-name changes to the Activity-name, but as I click it, the MainActivity pops up. However the title in the action-bar is the other activity-name. My manifest is at the moment this:

<application
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <activity
        android:name="com.example.protoone.MainActivity"
        android:label="@string/app_name" >
    </activity>
    <activity
        android:name="com.example.protoone.LoginActivity"
        android:label="@string/title_activity_login">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

My guess is that android.intent.action.MAIN launches my MainActivity, although I want the LoginActivity to be the one that appears first, obviously. Thanks for any help.

War es hilfreich?

Lösung

From the manifest you have posted it does appear that LoginActivity is started when the app is started. You should take a look at your code to see if LoginActivity is starting MainActivity, or if you are sharing layouts, or similar.

It's simple enough to put some debug information in your LoginActivity and see if it is started when your app is started. Remember that if you start an app and then come out of it (for example hitting the home button) then restarting it will often bring you back to where you were last rather than restarting it from the beginning.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top