この記事を作った動機
自分用の android studio におけるアプリ開発時に引っかかる部分の記録です。単にアクテビティなしのテンプレートからアプリを作ろうとしたとき、アプリ起動時のアクテビティを指定する必要があり、そのやり方を毎回忘れるというのが、この記事を書くきっかけです。
重要な部分(引用部分)
<intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter>
AndroidManifest.xml の全体像の例
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<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.FileShareViewsmb"
tools:targetApi="31">
<activity
android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
参考にしたサイトとか
- android - Change application’s starting activity - Stack Overflow
https://stackoverflow.com/questions/3631982/change-applications-starting-activity (2025年5月1日)