I'm trying to launch Amazon Prime for TV app (https://play.google.com/store/apps/details?id=com.amazon.amazonvideo.livingroom) from within my own Android TV app. Unfortunately, PackageManager.getLaunchIntentForPackage()
returns null.
// called inside a Fragment
val intent = activity?.packageManager?.getLaunchIntentForPackage("com.amazon.amazonvideo.livingroom")
startActivity(intent)
when run, it throws
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference
Of course, I do have Amazon Prime for TV installed on my Android TV. Also, I could use this code to succesfully launch other apps like com.google.android.youtube.tv
or com.netflix.ninja
There's a similiar question regarding this topic (how launch amazon prime video app from within my android app using intent), but it doesn't solve my problem - solution to OP's problem was to use PackageManager
(which I'm already using) and com.amazon.avod.thirdpartyclient
, since the app was running on phone/tablet instead of TV
EDIT: Intent.migrateExtraStreamToClipData() on a null object reference does not solve my problem. I have Google Play Services installed on my Android TV, version 11.5.09, while the bug causing the other question's problem was (supposedly) fixed in 9.4.0. Anyway, accepted solution is just about avoiding app crash, not fixing the real problem.