0

Scenario: Two Activities being shown in launcher for one app, they have different taskAffinities because I was getting the problem of when I open one, hit home, open the other, the first one would be opened. So, I added taskAffinity in the AndroidManifest for the proper tasks.

The problem I'm getting is that if I open one, hit home, hit the second one, it will open the proper task/Activity, BUT I have to click on the icon twice in order for it to open and get, this ONLY happens with the activity that specifies a taskAffinity, the other one opens just fine on the first click every time.

731-1337/? W/InputMethodManagerService﹕ Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4e640b6 attribute=null, token = android.os.BinderProxy@3edac0ca

Here is the manifest

<activity
        android:name=".firstActivity"
        android:theme="@android:style/Theme.Holo.Light.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>

<activity
            android:name=".secondActivity"
            android:label="@string/second_activity"
            android:icon="@drawable/ic_second_activity"
            android:taskAffinity="secondTask"
            android:theme="@android:style/Theme.Holo.Light.NoActionBar">

        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
</activity>
<activity android:name=".thirdActivity"
              android:label="@string/second_activity"
              android:taskAffinity="secondTask"
              android:theme="@android:style/Theme.Holo.Light.NoActionBar"/>
Shawn Hazen
  • 152
  • 1
  • 7

1 Answers1

0

I fixed this by adding this to the thirdActivty which was being called by secondActivity immediately on launch.

              android:launchMode="singleTask"

So it ended up looking like

<activity android:name=".thirdActivity"
          android:label="@string/second_activity"
          android:taskAffinity="secondTask"
          android:launchMode="singleTask"
          android:theme="@android:style/Theme.Holo.Light.NoActionBar"/>

Hope someone finds this solution helpful.

Shawn Hazen
  • 152
  • 1
  • 7