From aed2a7d5c539e8b4ef85564a22a71f1cc87dbbd0 Mon Sep 17 00:00:00 2001 From: Andrey Tkachenko Date: Sun, 13 Mar 2016 16:01:43 +0300 Subject: [PATCH] support for getLaunchIntentForPackage --- .gitignore | 6 ++---- manifest | 1 + .../packagemanager/PackagemanagerModule.java | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 5ced92e..788cff5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,9 +3,7 @@ bin build *.zip .apt_generated - /.project - -/.settings/ - +/.settings /build.properties +libs/ diff --git a/manifest b/manifest index 75f3ce2..f50e5ae 100644 --- a/manifest +++ b/manifest @@ -4,6 +4,7 @@ # version: 1.0 apiversion: 2 +architectures: armeabi armeabi-v7a x86 description: Packagemanager author: Timan Rebel license: The MIT License (MIT) diff --git a/src/nl/rebelic/packagemanager/PackagemanagerModule.java b/src/nl/rebelic/packagemanager/PackagemanagerModule.java index 3782fd4..8223f73 100644 --- a/src/nl/rebelic/packagemanager/PackagemanagerModule.java +++ b/src/nl/rebelic/packagemanager/PackagemanagerModule.java @@ -76,5 +76,20 @@ public boolean isIntentAvailable(IntentProxy intentProxy) { private boolean isSystemPackage(PackageInfo pkgInfo) { return ((pkgInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0) ? true : false; } + + /** + * Returns a "good" intent to launch a front-door activity in a package. This is used, for example, to implement an "open" button when browsing through packages. The current implementation looks first for a main activity in the category CATEGORY_INFO, and next for a main activity in the category CATEGORY_LAUNCHER. Returns null if neither are found. + * @param packageName The name of the package to inspect. + * @return + */ + @Kroll.method + public IntentProxy getLaunchIntentForPackage(String packageName) { + Intent intent = TiApplication.getAppRootOrCurrentActivity().getPackageManager().getLaunchIntentForPackage(packageName); + if(intent != null) { + return new IntentProxy(intent); + } + return null; + + } }