1

aid with this example at Return back to MainActivity from another activity I copy that codes as follow,

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
 <uses-sdk
    android:minSdkVersion="10"
    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" >
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />

        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
</activity>
<activity
    android:name=".Activity1"
    android:label="@string/title_activity_main" >
    <intent-filter>
        <action android:name="android.intent.action.ACTIVITY001" />

        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
<activity
    android:name=".Activity2"
    android:label="@string/title_activity_main" >
    <intent-filter>
        <action android:name="android.intent.action.ACTIVITY002" />

        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
<activity
    android:name=".Activity3"
    android:label="@string/title_activity_main" >
    <intent-filter>
        <action android:name="android.intent.action.ACTIVITY003" />

        <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>
</activity>
</application>

So many statements: action android:name="android.intent.action.MAIN"; if I would use their class path to instead of them, they can also do the job. what's different from these two ways?

Community
  • 1
  • 1
learner1
  • 123
  • 2
  • 3
  • 13

2 Answers2

0

its wrong

    <action android:name="ACTIVITYNAME FOR INTENT" />


    <category android:name=""/> // android.intent.action.DEFAULT or android.intent.action.MAIN

android.intent.action.MAIN is given to the activity wich is going to launch at first and

android.intent.action.OTHER to the rest of the activities getting called by other activities

Your application will refer to the manifest to fetch the activity for first launch , havin MAIN in it

Viswanath Lekshmanan
  • 9,945
  • 1
  • 40
  • 64
  • This answer is completely random. There is no category by the name of "`android.intent.category.MAIN`". The OP was asking about the action "`android.intent.action.MAIN`" – Price Feb 03 '15 at 13:06
  • @price thanx for pointing that. It was a mistake, I have updated that. – Viswanath Lekshmanan Feb 12 '15 at 04:08
0

setClass() is a explicit declaration, setAction() is a implicit declaration. It will find your target action im manifest.xml.

If the intent-filter with “android.intent.action.MAIN”, there would more entryance of your application, also you can found more icon in launcher.

Alec
  • 1