Android TV not starting correct activity
I have an app that should run on both phone and TV. In the manifest, I'm specifying the phone's launch activity with
<activity
android:name=".view.phone.MainActivity"
android:launchMode="singleTop"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
and the TV's launch activity with
<activity
android:name=".view.leanback.MainActivity"
android:launchMode="singleTop"
android:label="@string/app_name"
android:screenOrientation="landscape" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
</intent-filter>
</activity>
Instead of filtering between LAUNCHER & LEANBACK_LAUNCHER, on either device it just goes with whichever activity is declared first in the manifest. Any ideas what I'm doing wrong?
Solution for me was to create 2 launch configuration like this:
You are using the same Activity name MainActivity
to call both your TV and Phone App. Change one of these names and you should be good to go. As shown here in the first step, your activity name for the TV should be different than your activity name for the phone app.
上一篇: ECMAScript(ECMA。)中`reference'的`base value`是什么?
下一篇: Android TV无法启动正确的活动