For some reason every now and then my scripts that I use to launch apps on my Android TV stop working. I have buttons on my Dashboard that take me straight to the app I want to use so I don't have to touch the remote to get started..
Now when they stop working, the issue is always the adb command has stopped working and that the app name no longer works properly. This could be from an app update, I really not sure why.
It took me a while but I found a way to get the correct app name to pass to the adb command in HA.
Firstly connect to adb on your Android TV and open the shell, adb shell
From there it is really easy, type:
logcat | grep [app name]
Replace the app name with the name of the app you are trying to find the command for. If you are unsure of the name, you can run the command:
pm list packages
This will list all the applications installed on the TV and go through this to find the name of your app. It is unlikely you will need this step,but I thought I would include it for fullness of the help.
Now if you run the logcat command and nothing is returned, this is the best. As it means you haven't opened the app yet and the log will be much easier to read.
This is where you then use your remote to open your app on the TV. When I do this for the Kayo app, the first line returned is:
06-03 19:36:46.251 3057 4703 I ActivityTaskManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LEANBACK_LAUNCHER] flg=0x10000000 pkg=au.com.kayosports.tv cmp=au.com.kayosports.tv/.MainActivity} from uid 10222
The important part of this message is the text after the statement cmp= in my case that is "au.com.kayosports.tv/.MainActivity"
Then from there in your script for the adb command you use this:
adb shell am start -a android.intent.action.VIEW -n au.com.kayosports.tv/.MainActivity
My app now opens when I run the script.
I hope this helps someone as I have spent a couple of hours this afternoon working this out and thought I would share it with everyone.