diff --git a/process-phoenix/src/main/java/com/jakewharton/processphoenix/ProcessPhoenix.java b/process-phoenix/src/main/java/com/jakewharton/processphoenix/ProcessPhoenix.java index 7447b40..c7a5bda 100644 --- a/process-phoenix/src/main/java/com/jakewharton/processphoenix/ProcessPhoenix.java +++ b/process-phoenix/src/main/java/com/jakewharton/processphoenix/ProcessPhoenix.java @@ -19,6 +19,8 @@ import android.app.ActivityManager; import android.content.Context; import android.content.Intent; +import android.content.pm.PackageManager; +import android.os.Build; import android.os.Bundle; import android.os.Process; import java.util.ArrayList; @@ -27,6 +29,7 @@ import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; +import static android.content.pm.PackageManager.FEATURE_LEANBACK; /** * Process Phoenix facilitates restarting your application process. This should only be used for @@ -70,7 +73,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 (Build.VERSION.SDK_INT >= 21 && PackageManager.hasSystemFeature(FEATURE_LEANBACK)) { + // Use leanback intent if available, for Android TV apps. + defaultIntent = PackageManager.getLeanbackLaunchIntentForPackage(packageName); + } + if (defaultIntent == null) { + defaultIntent = PackageManager.getLaunchIntentForPackage(packageName); + } if (defaultIntent != null) { return defaultIntent; }