0

I've built a project that contains different packages and activities, say:

com.example.package1.Activity1
com.example.package2.Activity2

The first package holds a launcher. On my project manifest file this activity is listening to the home intent:

        // Launcher
        <activity android:name=".package1.Activity1" android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

        // package2.activity1
        <activity android:name=".package2.activity1" android:label="@string/package2_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

My problem is that when a user clicks Home the launcher isn't opened, instead the user is taken to the last opened activity of the app. EG: User opens package2.MainActivity from default launcher > goes to another app > clicks home > package2.MainActivity is opened again.

Is this normal? How do I make sure the device Home button takes to .package1.activity1?

lisovaccaro
  • 32,502
  • 98
  • 258
  • 410
  • Do u mean device "Home" button? – dd619 Jan 07 '13 at 05:28
  • yes, the hard button "home". Sorry I will clarify the question – lisovaccaro Jan 07 '13 at 05:36
  • Hmmm! User opens package2.MainActivity from default launcher > opens another app? you meant another activity or are you launching a new application? – Lazy Ninja Jan 07 '13 at 06:45
  • Sorry, I just posted a wrong answer. I meant actually launching another app (the user navigates away from my app and then clicks the home button), it's just for testing purposes since the home intent wouldn't do anything if the user didn't move to another app first. Am I clear yet or am I confusing things even more? – lisovaccaro Jan 07 '13 at 06:53

2 Answers2

1

If you are trying to create a HOME-screen replacement, then the activity for that needs to have the following in its <activity> tag in the manifest:

android:launchMode="singleInstance"

This will ensure that only one instance of this activity ever exists and that when this activity launches other activities that they will all go into new tasks and not be a part of the HOME-screen replacement's task.

David Wasser
  • 93,459
  • 16
  • 209
  • 274
0

I am not sure but please try to this code:

// package2.activity1
    <activity android:name=".package2.activity1" android:label="@string/package2_name" >
        <intent-filter>
            <action android:name="android.intent.action.View" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
Mahesh Kavathiya
  • 573
  • 5
  • 23