sbehnken
sbehnken

Reputation: 43

How do I know which is the MainActivity if it's not called MainActivity in Android Studio?

I'm new to programming and I'm learning/working on a friend's app. The MainActivity is not called MainActivity so I'm having a hard time figuring out which will be the first activity to show when it finally works. The app will compile but not run yet.

    <application
        android:name=".application.App"
        android:allowBackup="true"
        android:icon="@drawable/presentlylogo"
        android:label="@string/app_name"
        android:theme="@style/AppTheme"
        tools:replace="android:icon">


        <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

        <activity android:name=".activities.LoginActivity" />
        <activity android:name=".activities.details.DetailsPageActivity" />
        <activity
            android:name=".activities.create.CreateEventActivity"
            android:label="Create Event" />
        <activity
            android:name=".activities.create.MapLocationSelectionActivity"
            android:label="Select Location" />
        <activity android:name=".activities.settings.SettingsActivity">

        </activity>
        <activity
            android:name="com.facebook.FacebookActivity"
            android:label="Login"></activity>
        <activity
            android:name=".activities.NavigationActivity"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

Upvotes: 0

Views: 454

Answers (1)

Yit&#225;n117
Yit&#225;n117

Reputation: 46

You cand define in your Android Manifest which activity do you want to show when application start.

<activity
        android:name=".Splash.SplashActivity"
        android:theme="@style/splashScreen"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Into the activity label you can define it.

In this case, the first activity to show is SplashActivity (declared into android:name tag). if you want to change the first activity, write the name here.

For example, if you want to start with SomeActivity, your Manifest it could look like this.

<activity
        android:name=".[yourpackage].SomeActivity"
        android:theme="@style/splashScreen"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

Upvotes: 3

Related Questions