Reputation: 147
I have made a Timer application in android containing four activities.Now i when i install .apk in my android device it displays all four activity icons on screens rather than showing only main-activity icon..please help me..my manifest file is as below;
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timerdemo2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".NewProject"
android:label="@string/title_activity_main"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".Timedetails"
android:label="@string/title_activity_timedetails"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".ListActivity"
android:label="@string/title_activity_list"
android:screenOrientation="portrait" >
<intent-filter>
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_new_project"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 1
Views: 331
Reputation: 10969
It because you are applying </intent-filter>
to all activities instead to main, just make changes like below
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timerdemo2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
</intent-filter>
</activity>
<activity
android:name=".NewProject"
android:label="@string/title_activity_new_project"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".Timedetails"
android:label="@string/title_activity_timedetails"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".ListActivity"
android:label="@string/title_activity_list"
android:screenOrientation="portrait" >
</activity>
</application>
</manifest>
There is quite a bit of documentation on intent Filter
Upvotes: 1
Reputation: 3192
Try this code instead of above & Remember main activity of Application add tag
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
Your manifest Should be like this
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.timerdemo2"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".NewProject"
android:label="@string/title_activity_main"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".Timedetails"
android:label="@string/title_activity_timedetails"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".ListActivity"
android:label="@string/title_activity_list"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".MainActivity"
android:label="@string/title_activity_new_project"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Upvotes: 2
Reputation: 10395
Change your Intent Filters , the MAIN/LAUNCHER intent filter essentially tells android that the activity is the app's starting activity instead of using :
<action android:name="android.intent.action.MAIN" />
Use :
<action android:name="android.intent.action.VIEW" />
Upvotes: 0