List of usage examples for android.content.pm ResolveInfo loadLabel
public CharSequence loadLabel(PackageManager pm)
From source file:jahirfiquitiva.iconshowcase.tasks.LoadAppsToRequest.java
@SuppressLint("PrivateResource") public LoadAppsToRequest(Context context) { startTime = System.currentTimeMillis(); this.context = new WeakReference<>(context); debugging = context.getResources().getBoolean(R.bool.debugging); mPackageManager = context.getPackageManager(); ArrayList<ResolveInfo> rAllActivitiesList = (ArrayList<ResolveInfo>) context.getPackageManager() .queryIntentActivities(getAllActivitiesIntent(), 0); for (ResolveInfo info : rAllActivitiesList) { if (info.activityInfo.packageName.equals(context.getApplicationContext().getPackageName())) { continue; }//w ww. j av a2s.c o m RequestItem appInfo = new RequestItem(info.loadLabel(mPackageManager).toString(), info.activityInfo.packageName, info.activityInfo.name, getAppIcon(info), getNormalAppIcon(info, mPackageManager)); appsList.add(appInfo); } }
From source file:com.cocosw.bottomsheet.ActionMenu.java
public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) { PackageManager pm = mContext.getPackageManager(); final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0); final int N = lri != null ? lri.size() : 0; if ((flags & FLAG_APPEND_TO_GROUP) == 0) { removeGroup(groupId);/* w ww. ja va2 s. c o m*/ } for (int i = 0; i < N; i++) { final ResolveInfo ri = lri.get(i); Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]); rintent.setComponent( new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name)); final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)) .setIntent(rintent); if (outSpecificItems != null && ri.specificIndex >= 0) { outSpecificItems[ri.specificIndex] = item; } } return N; }
From source file:com.launcher.silverfish.AppDrawerTabFragment.java
/** * Loads apps from the database// w ww .jav a2s. co m */ private void loadApps() { Intent i = new Intent(Intent.ACTION_MAIN, null); i.addCategory(Intent.CATEGORY_LAUNCHER); switch (tabId) { case 1: // Tab 1 is a special tab and includes all except for the once in other tabs // so we retrieve all apps that are in the database LinkedList<String> ordered_apps = sqlHelper.getAllApps(); // And all installed apps on the device List<ResolveInfo> availableActivities = mPacMan.queryIntentActivities(i, 0); // And only add those that are not in the database for (int j = 0; j < availableActivities.size(); j++) { ResolveInfo ri = availableActivities.get(j); // Skip the apps that are in the database if (ordered_apps.contains(ri.activityInfo.packageName)) { continue; } AppDetail app = new AppDetail(); app.label = ri.loadLabel(mPacMan); app.name = ri.activityInfo.packageName; // Load the icon later in an async task. app.icon = null; appsList.add(app); } break; default: // All other tabs just query the apps from the database LinkedList<String> app_names = sqlHelper.getAppsForTab(tabId); for (String app_name : app_names) { boolean success = addAppToList(app_name); // If the app could not be added then it was probably uninstalled, // so we have to remove it from the database if (!success) { Log.d("DB", "Removing app " + app_name + " from db"); sqlHelper.removeAppFromTab(app_name, this.tabId); } } // show the empty category notice if this tab is empty if (app_names.size() == 0) { showEmptyCategoryNotice(); } } }
From source file:org.opensilk.music.ui2.loader.PluginLoader.java
private PluginInfo readResolveInfo(PackageManager pm, List<ComponentName> disabledPlugins, ResolveInfo resolveInfo) { boolean hasPermission = false; final String permission = resolveInfo.serviceInfo.permission; if (TextUtils.equals(permission, OrpheusApi.PERMISSION_BIND_LIBRARY_SERVICE) || TextUtils.equals(permission, "org.opensilk.music.debug.api.permission.BIND_LIBRARY_SERVICE")) { hasPermission = true;/* w ww . j a v a 2 s . c o m*/ } final CharSequence title = resolveInfo.loadLabel(pm); final ComponentName cn = getComponentName(resolveInfo); final Drawable icon = resolveInfo.loadIcon(pm); CharSequence description; try { Context packageContext = context.createPackageContext(cn.getPackageName(), 0); Resources packageRes = packageContext.getResources(); description = packageRes.getString(resolveInfo.serviceInfo.descriptionRes); } catch (PackageManager.NameNotFoundException e) { description = null; } PluginInfo pluginInfo = new PluginInfo(title, description, cn); pluginInfo.hasPermission = hasPermission; pluginInfo.icon = icon; for (ComponentName c : disabledPlugins) { if (c.equals(pluginInfo.componentName)) { pluginInfo.isActive = false; break; } } return pluginInfo; }
From source file:com.actionbarsherlock.internal.view.MenuBuilder.java
@Override public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, android.view.MenuItem[] outSpecificItems) { PackageManager pm = mContext.getPackageManager(); final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0); final int N = lri != null ? lri.size() : 0; if ((flags & FLAG_APPEND_TO_GROUP) == 0) { removeGroup(groupId);/*from ww w .j a v a 2 s . co m*/ } for (int i = 0; i < N; i++) { final ResolveInfo ri = lri.get(i); Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]); rintent.setComponent( new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name)); final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)) .setIntent(rintent); if (outSpecificItems != null && ri.specificIndex >= 0) { outSpecificItems[ri.specificIndex] = item; } } return N; }
From source file:com.androidzeitgeist.dashwatch.dashclock.ExtensionManager.java
/** * Returns a listing of all available (installed) extensions. *//*from w w w .j a v a2 s .c o m*/ public List<ExtensionListing> getAvailableExtensions() { List<ExtensionListing> availableExtensions = new ArrayList<ExtensionListing>(); PackageManager pm = mApplicationContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(DashClockExtension.ACTION_EXTENSION), PackageManager.GET_META_DATA); for (ResolveInfo resolveInfo : resolveInfos) { ExtensionListing listing = new ExtensionListing(); listing.componentName = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name); listing.title = resolveInfo.loadLabel(pm).toString(); Bundle metaData = resolveInfo.serviceInfo.metaData; if (metaData != null) { listing.protocolVersion = metaData.getInt("protocolVersion"); listing.worldReadable = metaData.getBoolean("worldReadable", false); listing.description = metaData.getString("description"); String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { listing.settingsActivity = ComponentName .unflattenFromString(resolveInfo.serviceInfo.packageName + "/" + settingsActivity); } } listing.icon = resolveInfo.loadIcon(pm); availableExtensions.add(listing); } return availableExtensions; }
From source file:com.google.android.apps.dashclock.ExtensionManager.java
/** * Returns a listing of all available (installed) extensions, including those that aren't * world-readable./* w ww.jav a2s .c om*/ */ public List<ExtensionListing> getAvailableExtensions() { List<ExtensionListing> availableExtensions = new ArrayList<>(); PackageManager pm = mApplicationContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(DashClockExtension.ACTION_EXTENSION), PackageManager.GET_META_DATA); for (ResolveInfo resolveInfo : resolveInfos) { ExtensionListing info = new ExtensionListing(); info.componentName( new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name)); info.title(resolveInfo.loadLabel(pm).toString()); Bundle metaData = resolveInfo.serviceInfo.metaData; if (metaData != null) { info.compatible(ExtensionHost.supportsProtocolVersion(metaData.getInt("protocolVersion"))); info.worldReadable(metaData.getBoolean("worldReadable", false)); info.description(metaData.getString("description")); String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { info.settingsActivity(ComponentName .unflattenFromString(resolveInfo.serviceInfo.packageName + "/" + settingsActivity)); } } info.icon(resolveInfo.getIconResource()); availableExtensions.add(info); } return availableExtensions; }
From source file:com.android.mylauncher3.allapps.AllAppsGridAdapter.java
public AllAppsGridAdapter(Launcher launcher, AlphabeticalAppsList apps, View.OnTouchListener touchListener, View.OnClickListener iconClickListener, View.OnLongClickListener iconLongClickListener) { Resources res = launcher.getResources(); mLauncher = launcher;//from w w w . java2 s . c o m mApps = apps; mEmptySearchMessage = res.getString(R.string.all_apps_loading_message); mGridSizer = new GridSpanSizer(); mGridLayoutMgr = new AppsGridLayoutManager(launcher); mGridLayoutMgr.setSpanSizeLookup(mGridSizer); mItemDecoration = new GridItemDecoration(); mLayoutInflater = LayoutInflater.from(launcher); mTouchListener = touchListener; mIconClickListener = iconClickListener; mIconLongClickListener = iconLongClickListener; mSectionNamesMargin = res.getDimensionPixelSize(R.dimen.all_apps_grid_view_start_margin); mSectionHeaderOffset = res.getDimensionPixelSize(R.dimen.all_apps_grid_section_y_offset); mSectionTextPaint = new Paint(); mSectionTextPaint.setTextSize(res.getDimensionPixelSize(R.dimen.all_apps_grid_section_text_size)); mSectionTextPaint.setColor(res.getColor(R.color.all_apps_grid_section_text_color)); mSectionTextPaint.setAntiAlias(true); mPredictedAppsDividerPaint = new Paint(); mPredictedAppsDividerPaint.setStrokeWidth(Utilities.pxFromDp(1f, res.getDisplayMetrics())); mPredictedAppsDividerPaint.setColor(0x1E000000); mPredictedAppsDividerPaint.setAntiAlias(true); mPredictionBarDividerOffset = (-res.getDimensionPixelSize(R.dimen.all_apps_prediction_icon_bottom_padding) + res.getDimensionPixelSize(R.dimen.all_apps_icon_top_bottom_padding)) / 2; // Resolve the market app handling additional searches PackageManager pm = launcher.getPackageManager(); ResolveInfo marketInfo = pm.resolveActivity(createMarketSearchIntent(""), PackageManager.MATCH_DEFAULT_ONLY); if (marketInfo != null) { mMarketAppName = marketInfo.loadLabel(pm).toString(); } }
From source file:com.quarterfull.newsAndroid.NewsDetailActivity.java
private boolean isChromeDefaultBrowser() { Intent browserIntent = new Intent("android.intent.action.VIEW", Uri.parse("http://")); ResolveInfo resolveInfo = getPackageManager().resolveActivity(browserIntent, PackageManager.MATCH_DEFAULT_ONLY); Log.v(TAG, "Default Browser is: " + resolveInfo.loadLabel(getPackageManager()).toString()); return (resolveInfo.loadLabel(getPackageManager()).toString().contains("Chrome")); }
From source file:com.google.android.apps.muzei.settings.SettingsChooseSourceFragment.java
public void updateSources() { mSelectedSource = null;//ww w . j a v a 2 s . co m Intent queryIntent = new Intent(ACTION_MUZEI_ART_SOURCE); PackageManager pm = getActivity().getPackageManager(); mSources.clear(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA); for (ResolveInfo ri : resolveInfos) { Source source = new Source(); source.label = ri.loadLabel(pm).toString(); source.icon = new BitmapDrawable(getResources(), generateSourceImage(ri.loadIcon(pm))); source.componentName = new ComponentName(ri.serviceInfo.packageName, ri.serviceInfo.name); if (ri.serviceInfo.descriptionRes != 0) { try { Context packageContext = getActivity() .createPackageContext(source.componentName.getPackageName(), 0); Resources packageRes = packageContext.getResources(); source.description = packageRes.getString(ri.serviceInfo.descriptionRes); } catch (PackageManager.NameNotFoundException e) { Log.e(TAG, "Can't read package resources for source " + source.componentName); } } Bundle metaData = ri.serviceInfo.metaData; source.color = Color.WHITE; if (metaData != null) { String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { source.settingsActivity = ComponentName .unflattenFromString(ri.serviceInfo.packageName + "/" + settingsActivity); } String setupActivity = metaData.getString("setupActivity"); if (!TextUtils.isEmpty(setupActivity)) { source.setupActivity = ComponentName .unflattenFromString(ri.serviceInfo.packageName + "/" + setupActivity); } source.color = metaData.getInt("color", source.color); try { float[] hsv = new float[3]; Color.colorToHSV(source.color, hsv); boolean adjust = false; if (hsv[2] < 0.8f) { hsv[2] = 0.8f; adjust = true; } if (hsv[1] > 0.4f) { hsv[1] = 0.4f; adjust = true; } if (adjust) { source.color = Color.HSVToColor(hsv); } if (Color.alpha(source.color) != 255) { source.color = Color.argb(255, Color.red(source.color), Color.green(source.color), Color.blue(source.color)); } } catch (IllegalArgumentException ignored) { } } mSources.add(source); } final String appPackage = getActivity().getPackageName(); Collections.sort(mSources, new Comparator<Source>() { @Override public int compare(Source s1, Source s2) { String pn1 = s1.componentName.getPackageName(); String pn2 = s2.componentName.getPackageName(); if (!pn1.equals(pn2)) { if (appPackage.equals(pn1)) { return -1; } else if (appPackage.equals(pn2)) { return 1; } } return s1.label.compareTo(s2.label); } }); redrawSources(); }