0
0

[Android] 最初に、表示するActivityを変更する方法

Posted at

app/manifestsフォルダに行く

AndroidManifest.xmlファイルを開く

<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    android:fullBackupContent="@xml/backup_rules"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.HappyBirthday"
    tools:targetApi="31">
    <activity
        android:name=".TaskCompleted"
        android:exported="false"
        android:label="@string/title_activity_task_completed"
        android:theme="@style/Theme.HappyBirthday" />
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:theme="@style/Theme.HappyBirthday">
    <!-- ここから下 -->
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    <!-- ここから上 -->
    </activity>
</application>

上記のファイルの下記の部分を、最初に表示させたいactivityのところに、移動させる

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

下記のコードのように移動すると、TaskCompleted.ktのactivityが最初に表示されるようになる

<application
    android:allowBackup="true"
    android:dataExtractionRules="@xml/data_extraction_rules"
    android:fullBackupContent="@xml/backup_rules"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:theme="@style/Theme.HappyBirthday"
    tools:targetApi="31">
    <activity
        android:name=".TaskCompleted"
        android:exported="true"
        android:label="@string/title_activity_task_completed"
        android:theme="@style/Theme.HappyBirthday">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity
        android:name=".MainActivity"
        android:exported="true"
        android:label="@string/app_name"
        android:theme="@style/Theme.HappyBirthday" />
</application>
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0