Skip to content

Commit

Permalink
fix: ensure the leanback intent is started on androidTv application
Browse files Browse the repository at this point in the history
  • Loading branch information
olivier committed Oct 20, 2023
1 parent 4cf6fca commit b510f1c
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.app.ActivityManager;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Process;
import java.util.ArrayList;
Expand Down Expand Up @@ -70,7 +71,16 @@ public static void triggerRebirth(Context context, Intent... nextIntents) {

private static Intent getRestartIntent(Context context) {
String packageName = context.getPackageName();
Intent defaultIntent = context.getPackageManager().getLaunchIntentForPackage(packageName);

PackageManager PackageManager = context.getPackageManager();
Intent defaultIntent = null;
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP
&& PackageManager.hasSystemFeature(PackageManager.FEATURE_LEANBACK)) {
defaultIntent = PackageManager.getLeanbackLaunchIntentForPackage(packageName);
} else {
defaultIntent = PackageManager.getLaunchIntentForPackage(packageName);
}

if (defaultIntent != null) {
return defaultIntent;
}
Expand Down

0 comments on commit b510f1c

Please sign in to comment.