Androidアプリケーションのデフォルトのアクティビティを設定する方法
Androidでは、 ”
AndroidManifest.xml
“の ”
intent-filter
“に従ってアプリケーションの開始アクティビティ(デフォルトアクティビティ)を設定できます。
アクティビティクラス ”
logoActivity
“をデフォルトのアクティビティとして設定するには、次のコードスニペットを参照してください。
ファイル:AndroidManifest.xml
<activity android:label="Logo" android:name=".logoActivity" > <intent-filter > <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity>
たとえば、2つのアクティビティクラスがあり、 “ListMobileActivity” “アクティビティをアプリケーションの開始アクティビティとして設定するとします。
ファイル:AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mkyong.android" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10"/> <application android:icon="@drawable/ic__launcher" android:label="@string/app__name" > <activity android:label="List of Mobile OS" android:name=".ListMobileActivity" > <intent-filter > <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <activity android:label="List of Fruits" android:name=".ListFruitActivity" > </activity> </application> </manifest>
一方、 “ListFruitActivity`”アクティビティを開始アクティビティとして設定する場合は、次のように ”
intent-filter
“をカットアンドペーストしてください:
File:AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mkyong.android" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="10"/> <application android:icon="@drawable/ic__launcher" android:label="@string/app__name" > <activity android:label="List of Mobile OS" android:name=".ListMobileActivity" > </activity> <activity android:label="List of Fruits" android:name=".ListFruitActivity" > <intent-filter > <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> </application> </manifest>
リンク://タグ/アンドロイド/[アンドロイド]リンク://タグ/アンドロイド – アクティビティ/[アンドロイド
アクティビティ]