diff options
author | Martijn Kaijser <machine.sanctum@gmail.com> | 2014-12-08 19:27:02 +0100 |
---|---|---|
committer | Martijn Kaijser <machine.sanctum@gmail.com> | 2014-12-08 19:27:02 +0100 |
commit | 6efc8127ab6047b62268be11e13e92cc57572535 (patch) | |
tree | 759c92c780b4c8593180ad3978bb2aacedbd6ffb | |
parent | 73c27b57eeb716c2e8cdb4fc537c5a1b5c87effd (diff) | |
parent | 0993862ec5b436cf5b142f1eb51e3e0122ac500a (diff) |
Merge pull request #5899 from koying/fixdroidleanback
FIX: [droid] fix launching leanback only apps
-rw-r--r-- | xbmc/android/activity/XBMCApp.cpp | 7 | ||||
-rw-r--r-- | xbmc/android/jni/PackageManager.cpp | 8 | ||||
-rw-r--r-- | xbmc/android/jni/PackageManager.h | 1 |
3 files changed, 15 insertions, 1 deletions
diff --git a/xbmc/android/activity/XBMCApp.cpp b/xbmc/android/activity/XBMCApp.cpp index 4a336e7257..f59ec3c1e8 100644 --- a/xbmc/android/activity/XBMCApp.cpp +++ b/xbmc/android/activity/XBMCApp.cpp @@ -71,6 +71,7 @@ #include "android/jni/Cursor.h" #include "android/jni/ContentResolver.h" #include "android/jni/MediaStore.h" +#include "android/jni/Build.h" #include "CompileInfo.h" #define GIGABYTES 1073741824 @@ -376,7 +377,9 @@ std::vector<androidPackage> CXBMCApp::GetApplications() newPackage.packageName = packageList.get(i).packageName; newPackage.packageLabel = GetPackageManager().getApplicationLabel(packageList.get(i)).toString(); CJNIIntent intent = GetPackageManager().getLaunchIntentForPackage(newPackage.packageName); - if (!intent || !intent.hasCategory("android.intent.category.LAUNCHER")) + if (!intent && CJNIBuild::SDK_INT >= 21) + intent = GetPackageManager().getLeanbackLaunchIntentForPackage(newPackage.packageName); + if (!intent) continue; m_applications.push_back(newPackage); @@ -426,6 +429,8 @@ bool CXBMCApp::StartActivity(const string &package, const string &intent, const GetPackageManager().getLaunchIntentForPackage(package) : CJNIIntent(intent); + if (!newIntent && CJNIBuild::SDK_INT >= 21) + newIntent = GetPackageManager().getLeanbackLaunchIntentForPackage(package); if (!newIntent) return false; diff --git a/xbmc/android/jni/PackageManager.cpp b/xbmc/android/jni/PackageManager.cpp index f61e7a288b..ddec8a72e6 100644 --- a/xbmc/android/jni/PackageManager.cpp +++ b/xbmc/android/jni/PackageManager.cpp @@ -42,6 +42,14 @@ CJNIIntent CJNIPackageManager::getLaunchIntentForPackage(const std::string &pack jcast<jhstring>(package)); } +CJNIIntent CJNIPackageManager::getLeanbackLaunchIntentForPackage(const std::string &package) +{ + // API 21 + return call_method<jhobject>(m_object, + "getLeanbackLaunchIntentForPackage", "(Ljava/lang/String;)Landroid/content/Intent;", + jcast<jhstring>(package)); +} + CJNIDrawable CJNIPackageManager::getApplicationIcon(const std::string &package) { return call_method<jhobject>(m_object, diff --git a/xbmc/android/jni/PackageManager.h b/xbmc/android/jni/PackageManager.h index 12fa1b44c1..5477b84008 100644 --- a/xbmc/android/jni/PackageManager.h +++ b/xbmc/android/jni/PackageManager.h @@ -34,6 +34,7 @@ public: ~CJNIPackageManager() {}; CJNIIntent getLaunchIntentForPackage(const std::string &package); + CJNIIntent getLeanbackLaunchIntentForPackage(const std::string &package); CJNIDrawable getApplicationIcon(const std::string &package); CJNIList<CJNIApplicationInfo> getInstalledApplications(int flags); CJNICharSequence getApplicationLabel(const CJNIApplicationInfo &info); |