List of usage examples for android.content.pm PackageManager queryIntentActivities
public abstract List<ResolveInfo> queryIntentActivities(Intent intent, @ResolveInfoFlags int flags);
From source file:com.android.mms.ui.MessageUtils.java
public static boolean isVCalendarAvailable(Context context) { final Intent intent = new Intent("android.intent.action.CALENDARCHOICE"); intent.setType("text/x-vcalendar"); final PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:com.android.mms.ui.MessageUtils.java
private static List<String> getHomes(Context context) { MmsLog.d(TAG, "DialogModeActivity.getHomes"); List<String> names = new ArrayList<String>(); PackageManager packageManager = context.getPackageManager(); Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); List<ResolveInfo> resolveInfo = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); for (ResolveInfo ri : resolveInfo) { names.add(ri.activityInfo.packageName); MmsLog.d(TAG, "package name=" + ri.activityInfo.packageName + " class name=" + ri.activityInfo.name); }//from ww w. j ava 2 s . c o m return names; }
From source file:org.mdc.chess.MDChess.java
private static boolean hasFenProvider(PackageManager manager) { Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.setType("application/x-chess-fen"); List<ResolveInfo> resolvers = manager.queryIntentActivities(i, 0); return (resolvers != null) && (resolvers.size() > 0); }
From source file:org.kontalk.ui.ComposeMessageFragment.java
/** Starts an activity for shooting a picture. */ private void selectPhotoAttachment() { try {/*ww w . j av a 2 s .c om*/ // check if camera is available final PackageManager packageManager = getActivity().getPackageManager(); final Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (list.size() <= 0) throw new UnsupportedOperationException(); mCurrentPhoto = MediaStorage.getOutgoingImageFile(); Uri uri = Uri.fromFile(mCurrentPhoto); Intent take = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); take.putExtra(MediaStore.EXTRA_OUTPUT, uri); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { take.setClipData(ClipData.newUri(getContext().getContentResolver(), "Picture path", uri)); } startActivityForResult(take, SELECT_ATTACHMENT_PHOTO); } catch (UnsupportedOperationException ue) { Toast.makeText(getActivity(), R.string.chooser_error_no_camera_app, Toast.LENGTH_LONG).show(); } catch (IOException e) { Log.e(TAG, "error creating temp file", e); Toast.makeText(getActivity(), R.string.chooser_error_no_camera, Toast.LENGTH_LONG).show(); } }
From source file:de.vanita5.twittnuker.util.Utils.java
public static boolean checkActivityValidity(final Context context, final Intent intent) { final PackageManager pm = context.getPackageManager(); return !pm.queryIntentActivities(intent, 0).isEmpty(); }
From source file:org.uguess.android.sysinfo.SiragonManager.java
private Intent getAboutSettingsIntent() { PackageManager pm = getActivity().getPackageManager(); Intent it = new Intent(Intent.ACTION_VIEW); // try the htc specifc settings first to avoid some broken manifest // issue on certain htc models it.setClassName("com.android.settings", //$NON-NLS-1$ "com.android.settings.framework.aboutphone.HtcAboutPhoneSettings"); //$NON-NLS-1$ List<ResolveInfo> acts = pm.queryIntentActivities(it, 0); if (acts.size() > 0) { return it; } else {//w ww . j av a 2 s. c o m // try the standard settings it.setClassName("com.android.settings", //$NON-NLS-1$ "com.android.settings.DeviceInfoSettings"); //$NON-NLS-1$ acts = pm.queryIntentActivities(it, 0); if (acts.size() > 0) { return it; } } return null; }
From source file:com.aliyun.homeshell.Folder.java
public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete, boolean success) { mDropAccepted = success;//from ww w . j a v a2 s. co m Log.d(TAG, "sxsexe---------> onDropCompleted dragInfo " + d.dragInfo + " success " + success + " mDeleteFolderOnDropCompleted " + mDeleteFolderOnDropCompleted + " mItemAddedBackToSelfViaIcon " + mItemAddedBackToSelfViaIcon + " item count " + getItemCount() + " mHasDirtyData " + mHasDirtyData); /*YUNOS BEGIN*/ //##module(component name) //##date:2014/03/28 ##author:jun.dongj@alibaba-inc.com##BugID:105531 //there is a cellayout outline when drag icon in folder, otherwise, hide it showDragOutline(false); /*YUNOS END*/ mShortcutInfoCache = (ShortcutInfo) d.dragInfo; mLauncher.setCurrentFolder(this); if (success) { if (target instanceof DeleteDropTarget && mShortcutInfoCache.itemType == Favorites.ITEM_TYPE_APPLICATION) { /* YUNOS BEGIN PB*/ //##modules(HomeShell): ##author:guoshuai.lgs //##BugID:(5221896) ##date:2014/09/03 //##decrpition: support mainmenu feature, cancel drop feature, page management feature, and so on if (!LauncherApplication.isMainmenuMode()) { //go to uninstall or remove, Log.d(TAG, "sxsexe---------> onDropCompleted do not need to replaceFolderWithFinalItem"); mHasDirtyData = true; /*YUNOS BEGIN*/ //##date:2014/01/18 ##author:hao.liuhaolh ##BugID:83464 //app icon remove issue in folder if ((mShortcutInfoCache.intent != null) && (mShortcutInfoCache.intent.getComponent() != null) && (mShortcutInfoCache.intent.getComponent().getPackageName() != null)) { boolean storgeMount = Environment.getExternalStorageState() .equals(Environment.MEDIA_MOUNTED); String packageName = mShortcutInfoCache.intent.getComponent().getPackageName(); final PackageManager packageManager = ((Context) mLauncher).getPackageManager(); final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null); mainIntent.addCategory(Intent.CATEGORY_LAUNCHER); mainIntent.setPackage(packageName); final List<ResolveInfo> apps = packageManager.queryIntentActivities(mainIntent, 0); if ((apps == null || apps.size() == 0) && (storgeMount == true)) { Log.d(TAG, "no app info, so it need to be cleaned"); mHasDirtyData = false; } } } /*YUNOS END PB*/ /*YUNOS END*/ } /*YUNOS BEGIN*/ //##date:2014/7/2 ##author:yangshan.ys##BugID:134407 //if the target is workspace or hotseat when drag or fling icon ,call this method mDeleteFolderOnDropCompleted = mInfo.count() <= 1; if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && !(target instanceof DeleteDropTarget)) { /*YUNOS END*/ if (!mHasDirtyData) { //drag to workspace or hotseat replaceFolderWithFinalItem(); this.setNeedReplaceFolderWithFinalItemFlase(); } } } else { Log.d(TAG, "sxsexe---------> onDropCompleted drag failed need to get the item back "); /*YUNOS BEGIN*/ //##date:2014/06/18 ##author:guoshuai.lgs ##BugID: //support the folder feature in mainmenu if (LauncherApplication.isMainmenuMode() && (mInfo.isMainmenuFolder())) { // Exit spring loaded mode if we have not successfully dropped or have not handled the // drop in Workspace //Delete the dragview d.deferDragViewCleanupPostAnimation = false; mLauncher.exitSpringLoadedDragMode(); } else { // The drag failed, we need to return the item to the folder mFolderIcon.onDrop(d); } /*YUNOS END*/ // We're going to trigger a "closeFolder" which may occur before this item has // been added back to the folder -- this could cause the folder to be deleted if (mOnExitAlarm.alarmPending()) { mSuppressFolderDeletion = true; } } if (target != this) { if (mOnExitAlarm.alarmPending()) { mOnExitAlarm.cancelAlarm(); completeDragExit(); } } mDeleteFolderOnDropCompleted = false; mDragInProgress = false; mItemAddedBackToSelfViaIcon = false; mCurrentDragInfo = null; mCurrentDragView = null; mSuppressOnAdd = false; /* YUNOS BEGIN */ // ##date:2014/07/04 ##author:yangshan.ys##BugID:135044 // prevent the position of editfoldericon moving in folder if (target == this && mInfo.isEditFolderInContents() && mEditFolderTempView != null) { int childId = mEditFolderTempView.getId(); CellLayout.LayoutParams params = (CellLayout.LayoutParams) mEditFolderTempView.getLayoutParams(); mContentList.get(mInfo.getmEditFolderShortcutInfo().screen).addViewToCellLayout(mEditFolderTempView, -1, childId, params, true); mEditFolderHidden = false; } /* YUNOS END */ // Reordering may have occured, and we need to save the new item locations. We do this once // at the end to prevent unnecessary database operations. /*YUNOS BEGIN*/ //##date:2014/06/10 ##author:guoshuai.lgs ##BugID: //support the folder feature in mainmenu if (mInfo.isMainmenuFolder() && (LauncherApplication.isMainmenuMode())) { // TODO: do nothing? } else { updateItemLocationsInDatabase(); } /*YUNOS END*/ mLauncher.getWorkspace().cleanDragInfoFromFolder(); mLauncher.getWorkspace().checkAndRemoveEmptyCell(); }
From source file:com.androzic.Androzic.java
public void initializePlugins() { PackageManager packageManager = getPackageManager(); List<ResolveInfo> plugins; Intent initializationIntent = new Intent("com.androzic.plugins.action.INITIALIZE"); // enumerate initializable plugins plugins = packageManager.queryBroadcastReceivers(initializationIntent, 0); for (ResolveInfo plugin : plugins) { // send initialization broadcast, we send it directly instead of sending // one broadcast for all plugins to wake up stopped plugins: // http://developer.android.com/about/versions/android-3.1.html#launchcontrols Intent intent = new Intent(); intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name); intent.setAction(initializationIntent.getAction()); sendBroadcast(intent);//from w w w. j a v a 2 s . c o m } // enumerate plugins with preferences plugins = packageManager.queryIntentActivities(new Intent("com.androzic.plugins.preferences"), 0); for (ResolveInfo plugin : plugins) { Intent intent = new Intent(); intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name); pluginPreferences.put(plugin.activityInfo.loadLabel(packageManager).toString(), intent); } // enumerate plugins with views plugins = packageManager.queryIntentActivities(new Intent("com.androzic.plugins.view"), 0); for (ResolveInfo plugin : plugins) { // get menu icon Drawable icon = null; try { Resources resources = packageManager .getResourcesForApplication(plugin.activityInfo.applicationInfo); int id = resources.getIdentifier("ic_menu_view", "drawable", plugin.activityInfo.packageName); if (id != 0) icon = resources.getDrawable(id); } catch (Resources.NotFoundException e) { e.printStackTrace(); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } Intent intent = new Intent(); intent.setClassName(plugin.activityInfo.packageName, plugin.activityInfo.name); Pair<Drawable, Intent> pair = new Pair<>(icon, intent); pluginViews.put(plugin.activityInfo.loadLabel(packageManager).toString(), pair); } }