List of usage examples for android.content.pm PackageManager GET_ACTIVITIES
int GET_ACTIVITIES
To view the source code for android.content.pm PackageManager GET_ACTIVITIES.
Click Source Link
From source file:com.byhook.cordova.chromelauncher.ChromeLauncher.java
private boolean isInstalled(String uri) { PackageManager pm = ((Activity) cordova).getPackageManager(); try {/*from ww w. j a va 2s . c o m*/ pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { } return false; }
From source file:com.mobivery.greent.MVYBatteryManagerActivityFragment.java
public static boolean isApplicationBroughtToBackground(final Activity activity) { ActivityManager activityManager = (ActivityManager) activity.getSystemService(Context.ACTIVITY_SERVICE); List<ActivityManager.RunningTaskInfo> tasks = activityManager.getRunningTasks(1); // Check the top Activity against the list of Activities contained in the Application's package. if (!tasks.isEmpty()) { ComponentName topActivity = tasks.get(0).topActivity; try {// ww w . j ava 2 s. c o m PackageInfo pi = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_ACTIVITIES); for (ActivityInfo activityInfo : pi.activities) { if (topActivity.getClassName().equals(activityInfo.name)) return false; } } catch (PackageManager.NameNotFoundException e) { return false; // Never happens. } } return true; }
From source file:org.apache.cordova.startapp.startApp.java
/** * checkApp/*from w ww . j a va 2 s. c o m*/ */ public void check(String component, CallbackContext callback, Context context) { PackageManager pm = context.getPackageManager(); try { pm.getPackageInfo(component, PackageManager.GET_ACTIVITIES); callback.success(); } catch (Exception e) { callback.error(e.toString()); } }
From source file:cz.martykan.webtube.MenuHelper.java
public void setUpMenu(final ActionMenuView actionMenu, final DrawerLayout drawerLayout, final View bookmarksPanel) { this.drawerLayout = drawerLayout; this.bookmarksPanel = bookmarksPanel; this.actionMenu = actionMenu; actionMenu.setOnMenuItemClickListener(this); // Enable special buttons Menu menu = actionMenu.getMenu(); PackageManager pm = context.getPackageManager(); menu.findItem(R.id.action_backgroundPlay) .setChecked(sp.getBoolean(BackgroundPlayHelper.PREF_BACKGROUND_PLAY_ENABLED, true)); menu.findItem(R.id.action_accept_cookies).setChecked(sp.getBoolean(PREF_COOKIES_ENABLED, true)); // Tor button if (OrbotHelper.isOrbotInstalled(context.getApplicationContext())) { menu.findItem(R.id.action_tor).setEnabled(true) .setChecked(sp.getBoolean(TorHelper.PREF_TOR_ENABLED, false)); }/*from w w w. j a va2 s. c om*/ // Add Kodi button try { pm.getPackageInfo("org.xbmc.kore", PackageManager.GET_ACTIVITIES); menu.findItem(R.id.action_cast_to_kodi).setEnabled(true); } catch (PackageManager.NameNotFoundException e) { /* Kodi is not installed */ } }
From source file:cc.metapro.openct.utils.CrashHandler.java
private void dumpPhoneInfo(PrintWriter pw) throws PackageManager.NameNotFoundException { PackageManager pm = mContext.getPackageManager(); PackageInfo pi = pm.getPackageInfo(mContext.getPackageName(), PackageManager.GET_ACTIVITIES); pw.print("OpenCT Version: "); pw.print(pi.versionName);//from w w w . j a va 2 s . com pw.print("_"); pw.println(pi.versionCode); pw.print("OS Version: "); pw.print(Build.VERSION.RELEASE); pw.print("_"); pw.println(Build.VERSION.SDK_INT); pw.print("Vendor: "); pw.println(Build.MANUFACTURER); pw.print("Model: "); pw.println(Build.MODEL); }
From source file:com.github.fi3te.iliasdownloader.view.Eula.java
private static PackageInfo getPackageInfo(Activity activity) { PackageInfo pi = null;/* ww w . ja v a2 s .c o m*/ try { pi = activity.getPackageManager().getPackageInfo(activity.getPackageName(), PackageManager.GET_ACTIVITIES); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return pi; }
From source file:org.adaway.util.ScanAdwareLoader.java
/** * Finds all installed packages that look like they include a known ad framework *//*from w w w . j a va2 s . c o m*/ private List<PackageInfo> getAdPackages() { Set<PackageInfo> adPackages = new HashSet<PackageInfo>(); PackageManager pm = context.getPackageManager(); // It'd be simpler to just use pm.getInstalledPackages here, but apparently it's broken List<ApplicationInfo> appInfos = pm.getInstalledApplications(0); for (ApplicationInfo appInfo : appInfos) { if (canceled) { adPackages.clear(); break; } try { PackageInfo pkgInfo = pm.getPackageInfo(appInfo.packageName, PackageManager.GET_ACTIVITIES | PackageManager.GET_RECEIVERS | PackageManager.GET_SERVICES); Log.v(Constants.TAG, "Scanning package " + pkgInfo.packageName); if (pkgInfo.activities != null) { for (ActivityInfo activity : pkgInfo.activities) { Log.v(Constants.TAG, "[ACTIVITY] " + activity.name); for (String adPackagePrefix : AD_PACKAGE_PREFIXES) { if (activity.name.startsWith(adPackagePrefix)) { Log.i(Constants.TAG, "Detected ad framework prefix " + adPackagePrefix + " in package " + pkgInfo.packageName + " as activity " + activity.name); adPackages.add(pkgInfo); } } } } if (pkgInfo.receivers != null) { for (ActivityInfo receiver : pkgInfo.receivers) { Log.v(Constants.TAG, "[RECEIVER] " + receiver.name); for (String adPackagePrefix : AD_PACKAGE_PREFIXES) { if (receiver.name.startsWith(adPackagePrefix)) { Log.i(Constants.TAG, "Detected ad framework prefix " + adPackagePrefix + " in package " + pkgInfo.packageName + " as receiver " + receiver.name); adPackages.add(pkgInfo); break; } } } } if (pkgInfo.services != null) { for (ServiceInfo service : pkgInfo.services) { Log.v(Constants.TAG, "[SERVICE] " + service.name); for (String adPackagePrefix : AD_PACKAGE_PREFIXES) { if (service.name.startsWith(adPackagePrefix)) { Log.i(Constants.TAG, "Detected ad framework prefix " + adPackagePrefix + " in package " + pkgInfo.packageName + " as service " + service.name); adPackages.add(pkgInfo); break; } } } } } catch (Exception e) { Log.e(Constants.TAG, "Scan Adware Exception", e); } } return new ArrayList<PackageInfo>(adPackages); }
From source file:com.dm.material.dashboard.candybar.fragments.ApplyFragment.java
private boolean isPackageInstalled(String pkg) { try {// w w w . j a v a 2 s. co m PackageInfo packageInfo = getActivity().getPackageManager().getPackageInfo(pkg, PackageManager.GET_ACTIVITIES); return packageInfo != null; } catch (Exception e) { return false; } }
From source file:it.unibs.sandroide.lib.BLEContext.java
public static boolean isAppInstalled(String uri) { PackageManager pm = BLEContext.context.getPackageManager(); try {//w ww .ja v a 2 s . c o m pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { } return false; }
From source file:com.actionbarsherlock.internal.app.ActionBarHandlerWatson.java
@Override protected void performAttach() { getActivity().requestWindowFeature(Window.FEATURE_NO_TITLE); setActivityContentView(R.layout.actionbarwatson_wrapper); mActionBar = (ActionBarWatson) getActivity().findViewById(R.id.actionbarwatson); mContentView = (FrameLayout) getActivity().findViewById(R.id.actionbarsherlock_content); final MenuItemImpl homeMenuItem = getHomeMenuItem(); final ActionBarWatson.Item homeItem = mActionBar.getHomeItem(); final WatsonItemViewWrapper homeWrapper = new WatsonItemViewWrapper(homeItem); homeWrapper.initialize(homeMenuItem, MenuBuilder.TYPE_WATSON); homeMenuItem.setItemView(MenuBuilder.TYPE_WATSON, homeWrapper); final PackageManager pm = getActivity().getPackageManager(); final ApplicationInfo appInfo = getActivity().getApplicationInfo(); ActivityInfo actInfo = null;/*w w w.java 2 s. co m*/ try { actInfo = pm.getActivityInfo(getActivity().getComponentName(), PackageManager.GET_ACTIVITIES); } catch (NameNotFoundException e) { } if ((actInfo != null) && (actInfo.labelRes != 0)) { //Load label string resource from the activity entry mActionBar.setTitle(actInfo.labelRes); } else if (mActionBar.getTitle() == null) { //No activity label string resource and none in theme mActionBar.setTitle(actInfo.loadLabel(pm)); } if ((actInfo != null) && (actInfo.icon != 0)) { //Load the icon from the activity entry homeItem.setIcon(actInfo.icon); } else if (homeItem.getIcon() == null) { //No activity icon and none in theme homeItem.setIcon(pm.getApplicationIcon(appInfo)); } //XXX LOGO LOADING DOES NOT WORK //XXX SEE: http://stackoverflow.com/questions/6105504/load-activity-and-or-application-logo-programmatically-from-manifest //XXX SEE: https://groups.google.com/forum/#!topic/android-developers/UFR4l0ZwJWc //if ((actInfo != null) && (actInfo.logo != 0)) { // //Load the logo from the activity entry // homeItem.setLogo(actInfo.logo); //} else if ((homeItem.getLogo() == null) && (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD)) { // //No activity logo and none in theme // homeItem.setLogo(appInfo.logo); //} }