Change application's starting activity

前端 未结 11 2025
温柔的废话
温柔的废话 2020-11-22 16:51

I have created the meat and guts of my application but I want to add a different activity that will be the starting point (sort of a log-in screen).

Couple questions

相关标签:
11条回答
  • 2020-11-22 17:41
     <activity android:name=".MainActivity">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN" />
                    <category android:name="android.intent.category.LAUNCHER" />
                </intent-filter>
            </activity>
    
    0 讨论(0)
  • 2020-11-22 17:43

    Go to AndroidManifest.xml in the root folder of your project and change the Activity name which you want to execute first.

    Example:

    <activity android:name=".put your started activity name here"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    
    0 讨论(0)
  • 2020-11-22 17:45

    Follow to below instructions:

    1:) Open your AndroidManifest.xml file.

    2:) Go to the activity code which you want to make your main activity like below.

    such as i want to make SplashScreen as main activity

    <activity
        android:name=".SplashScreen"
        android:screenOrientation="sensorPortrait"
        android:label="City Retails">
    </activity>
    

    3:) Now copy the below code in between activity tags same as:

    <activity
        android:name=".SplashScreen"
        android:screenOrientation="sensorPortrait"
        android:label="City Retails">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    

    and also check that newly added lines are not attached with other activity tags.

    0 讨论(0)
  • 2020-11-22 17:47

    If you are using Android Studio and you might have previously selected another Activity to launch.

    Click on Run > Edit configuration and then make sure that Launch default Activity is selected.

    Launch default Activity

    0 讨论(0)
  • 2020-11-22 17:48

    You add this you want to launch activity android:exported="true" in manifest file like

     <activity
          android:name=".activities.activity.MainActivity"
          android:windowSoftInputMode="adjustPan"
          android:exported="true"/>
      <activity
    

    Open java file of this activity and right click then click on Run 'main Activity'

    OR

    Open java file of this activity and press Ctrl+Shift+F10.

    0 讨论(0)
提交回复
热议问题