Reputation: 2066
I got an Android App and I want it to replace the default launcher on my android box. My AndroidManifest.xml file contains these lines:
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:hardwareAccelerated="true"
android:windowSoftInputMode="stateAlwaysHidden"
android:screenOrientation="landscape"
android:usesCleartextTraffic="true">
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:launchMode="singleInstance">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
Many tutorials show that the last two categories have to be added in order to classify my app as a custom launcher.
Also, in my MainActivity.cs there are these lines:
[Activity(Label = "@string/app_name", Name = "com.MediaKind.Mediaroom.MainActivity", Theme = "@style/AppTheme.NoActionBar", MainLauncher = true)]
public class MainActivity : AppCompatActivity, TV2Client.IHost, ISurfaceHolderCallback2
I created my Signed APK with VS 2019, and pushed it to the device with the following line:
adb push <path to apk> system/priv-app/Mediaroom/
I pushed it there so it can be a system app.
After that, I went to adb shell and disabled the default leanback launcher, like this:
adb shell pm hide com.google.android.leanbacklauncher
After that, I rebooted the device in hope that the device will start with my app, but it didn't. No errors wahtsoever on logcat.
Also, I work on an Android TV, not on a smartphone, and my concern is that I found multiple sources that indicate that it is not possible anymore since the Marshmallow release.
If you need anything more, please tell me.
And thank you for reading this.
Upvotes: 1
Views: 2028
Reputation: 2066
After a lot of research, I found out that the default google leanback launcher has a higher priority than my custom launcher.
Googles launcher has a priority of 2, which means everything bellow 2 wont be taken into consideration.
To solve that, you need to edit the intent-filter like this:
<intent-filter android:priority="3">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
Just add the android:priority="3" to the intent-filter, if you want your launcher to be automatically added as default, just set priority to 3, and it is done, but when you want every time to choose the launcher on start-up, set the priority to 2, because 2 it's the default priority fot the google leanback launcher.
Hope this helps the next guy in need.
Upvotes: 3