From 970417c7d3e33ccbd6918e28d9bc5da24651f5b3 Mon Sep 17 00:00:00 2001 From: Jose Lima Date: Thu, 10 Apr 2014 10:42:19 -0700 Subject: Added getLeanbackLaunchIntentForPackage() Change-Id: I23be3bfa59be812a915adc37e08fdf59be8ad90f --- core/java/android/app/ApplicationPackageManager.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'core/java/android/app/ApplicationPackageManager.java') diff --git a/core/java/android/app/ApplicationPackageManager.java b/core/java/android/app/ApplicationPackageManager.java index 6f53df4..010988e 100644 --- a/core/java/android/app/ApplicationPackageManager.java +++ b/core/java/android/app/ApplicationPackageManager.java @@ -129,6 +129,24 @@ final class ApplicationPackageManager extends PackageManager { } @Override + public Intent getLeanbackLaunchIntentForPackage(String packageName) { + // Try to find a main leanback_launcher activity. + Intent intentToResolve = new Intent(Intent.ACTION_MAIN); + intentToResolve.addCategory(Intent.CATEGORY_LEANBACK_LAUNCHER); + intentToResolve.setPackage(packageName); + List ris = queryIntentActivities(intentToResolve, 0); + + if (ris == null || ris.size() <= 0) { + return null; + } + Intent intent = new Intent(intentToResolve); + intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); + intent.setClassName(ris.get(0).activityInfo.packageName, + ris.get(0).activityInfo.name); + return intent; + } + + @Override public int[] getPackageGids(String packageName) throws NameNotFoundException { try { -- cgit v1.1