List of usage examples for android.content.pm ResolveInfo loadLabel
public CharSequence loadLabel(PackageManager pm)
From source file:com.androidzeitgeist.dashwatch.muzei.SourceManager.java
public List<SourceListing> getAvailableSources() { List<SourceListing> sources = new ArrayList<SourceListing>(); PackageManager pm = mApplicationContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(new Intent(MuzeiArtSource.ACTION_MUZEI_ART_SOURCE), PackageManager.GET_META_DATA); for (ResolveInfo resolveInfo : resolveInfos) { SourceListing listing = new SourceListing(); listing.componentName = new ComponentName(resolveInfo.serviceInfo.packageName, resolveInfo.serviceInfo.name); listing.title = resolveInfo.loadLabel(pm).toString(); sources.add(listing);//from w ww . j a va2 s. c om } return sources; }
From source file:owne.android.envmonitor.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);/* w ww . j a va2 s . com*/ mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(action); mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); } }); container.addView(item); } }
From source file:no.android.proxime.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);/* w w w. ja v a2s .c om*/ mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(action); mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:com.buddi.client.dfu.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);/*w w w.j a v a2 s. c om*/ mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } }); // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:com.example.RITW.proximity.FeaturesActivity.java
private void setupPluginsInDrawer(final ViewGroup container) { final LayoutInflater inflater = LayoutInflater.from(this); final PackageManager pm = getPackageManager(); // look for Master Control Panel final Intent mcpIntent = new Intent(Intent.ACTION_MAIN); mcpIntent.setClassName(MCP_PACKAGE, MCP_CLASS); final ResolveInfo mcpInfo = pm.resolveActivity(mcpIntent, 0); // configure link to Master Control Panel //final TextView mcpItem = (TextView) container.findViewById(R.id.link_mcp); if (mcpInfo == null) { // mcpItem.setTextColor(Color.GRAY); ColorMatrix grayscale = new ColorMatrix(); grayscale.setSaturation(0.0f);/*from ww w.j a v a2 s . co m*/ // mcpItem.getCompoundDrawables()[0].setColorFilter(new ColorMatrixColorFilter(grayscale)); } /*mcpItem.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { Intent action = mcpIntent; if (mcpInfo == null) action = new Intent(Intent.ACTION_VIEW, Uri.parse(MCP_MARKET_URI)); action.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); try { startActivity(action); } catch (final ActivityNotFoundException e) { Toast.makeText(FeaturesActivity.this, R.string.no_application_play, Toast.LENGTH_SHORT).show(); } mDrawerLayout.closeDrawers(); } });*/ // look for other plug-ins final Intent utilsIntent = new Intent(Intent.ACTION_MAIN); utilsIntent.addCategory(UTILS_CATEGORY); final List<ResolveInfo> appList = pm.queryIntentActivities(utilsIntent, 0); for (final ResolveInfo info : appList) { final View item = inflater.inflate(R.layout.drawer_plugin, container, false); final ImageView icon = (ImageView) item.findViewById(android.R.id.icon); final TextView label = (TextView) item.findViewById(android.R.id.text1); label.setText(info.loadLabel(pm)); icon.setImageDrawable(info.loadIcon(pm)); item.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(); intent.setComponent(new ComponentName(info.activityInfo.packageName, info.activityInfo.name)); intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivity(intent); mDrawerLayout.closeDrawers(); } }); container.addView(item); } }
From source file:com.battlelancer.seriesguide.extensions.ExtensionManager.java
/** * Queries the {@link android.content.pm.PackageManager} for any installed {@link * com.battlelancer.seriesguide.api.SeriesGuideExtension} extensions. Their info is extracted * into {@link com.battlelancer.seriesguide.extensions.ExtensionManager.Extension} objects. *///from ww w . j a va 2s .com public List<Extension> queryAllAvailableExtensions() { Intent queryIntent = new Intent(SeriesGuideExtension.ACTION_SERIESGUIDE_EXTENSION); PackageManager pm = mContext.getPackageManager(); List<ResolveInfo> resolveInfos = pm.queryIntentServices(queryIntent, PackageManager.GET_META_DATA); List<Extension> extensions = new ArrayList<>(); for (ResolveInfo info : resolveInfos) { Extension extension = new Extension(); // get label, icon and component name extension.label = info.loadLabel(pm).toString(); extension.icon = info.loadIcon(pm); extension.componentName = new ComponentName(info.serviceInfo.packageName, info.serviceInfo.name); // get description Context packageContext; try { packageContext = mContext.createPackageContext(extension.componentName.getPackageName(), 0); Resources packageRes = packageContext.getResources(); extension.description = packageRes.getString(info.serviceInfo.descriptionRes); } catch (SecurityException | PackageManager.NameNotFoundException | Resources.NotFoundException e) { Timber.e(e, "Reading description for extension " + extension.componentName + " failed"); extension.description = ""; } // get (optional) settings activity Bundle metaData = info.serviceInfo.metaData; if (metaData != null) { String settingsActivity = metaData.getString("settingsActivity"); if (!TextUtils.isEmpty(settingsActivity)) { extension.settingsActivity = ComponentName .unflattenFromString(info.serviceInfo.packageName + "/" + settingsActivity); } } Timber.d("queryAllAvailableExtensions: found extension " + extension.label + " " + extension.componentName); extensions.add(extension); } return extensions; }
From source file:com.abhijitvalluri.android.fitnotifications.AppChoicesActivity.java
private Void appListTask() { List<ResolveInfo> packages = Func.getInstalledPackages(mPackageManager); // getAppSelectionsSubList is also needed for the subsequent calls to contains() List<AppSelection> appSelections = mAppSelectionsStore.getAppSelections(); for (ResolveInfo info : packages) { String appPackageName = info.activityInfo.packageName; String appName = info.loadLabel(mPackageManager).toString(); if (!mAppSelectionsStore.contains(appPackageName) && !appPackageName.equals(Constants.PACKAGE_NAME)) { mAppSelectionsStore.addAppSelection(new AppSelection(appPackageName, appName)); }/*from ww w .j a v a2 s . c om*/ } // Remove uninstalled apps from the database. for (AppSelection appSelection : appSelections) { if (isUninstalled(appSelection.getAppPackageName(), packages)) { mAppSelectionsStore.deleteAppSelection(appSelection); } } return null; }
From source file:edu.mit.mobile.android.demomode.DemoMode.java
/** * Loads the list of installed applications in mApplications. *///from www. j ava 2 s . co m private void loadApplications(boolean isLaunching) { if (isLaunching && mApplications != null) { return; } final PackageManager manager = getPackageManager(); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); final List<ResolveInfo> apps = manager.queryIntentActivities(mainIntent, 0); Collections.sort(apps, new ResolveInfo.DisplayNameComparator(manager)); if (apps != null) { final int count = apps.size(); if (mApplications == null) { mApplications = new ArrayList<ApplicationInfo>(count); } mApplications.clear(); for (int i = 0; i < count; i++) { final ApplicationInfo application = new ApplicationInfo(); final ResolveInfo info = apps.get(i); application.title = info.loadLabel(manager); application.setActivity( new ComponentName(info.activityInfo.applicationInfo.packageName, info.activityInfo.name), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED); application.icon = info.activityInfo.loadIcon(manager); mApplications.add(application); } } }
From source file:jahirfiquitiva.iconshowcase.tasks.LoadAppsToRequest.java
@SuppressLint("PrivateResource") private ArrayList<RequestItem> createListFromXML(Context context) { ArrayList<RequestItem> activitiesToRemove = new ArrayList<>(); try {/* w w w . jav a 2 s .c o m*/ XmlPullParserFactory xmlFactory = XmlPullParserFactory.newInstance(); XmlPullParser xmlParser = xmlFactory.newPullParser(); InputStream inputStream = context.getResources().openRawResource(R.raw.appfilter); xmlParser.setInput(inputStream, null); int activity = xmlParser.getEventType(); while (activity != XmlPullParser.END_DOCUMENT) { String name = xmlParser.getName(); switch (activity) { case XmlPullParser.START_TAG: break; case XmlPullParser.END_TAG: if (name.equals("item")) { ResolveInfo info = getResolveInfo(gComponentString(xmlParser, context)); if (info != null) { RequestItem appInfo = new RequestItem(info.loadLabel(mPackageManager).toString(), info.activityInfo.packageName, info.activityInfo.name, getAppIcon(info), getNormalAppIcon(info, mPackageManager)); activitiesToRemove.add(appInfo); } } break; } activity = xmlParser.next(); } } catch (IOException | XmlPullParserException e) { //Do nothing } return activitiesToRemove; }
From source file:com.actionbarsherlock.internal.view.menu.ActionMenu.java
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);// 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; }