List of usage examples for android.content.pm PackageManager GET_INTENT_FILTERS
int GET_INTENT_FILTERS
To view the source code for android.content.pm PackageManager GET_INTENT_FILTERS.
Click Source Link
From source file:Main.java
public static boolean isSupportSinaSSO(Context context) { Intent intent = new Intent("com.sina.weibo.remotessoservice"); List<ResolveInfo> list = context.getPackageManager().queryIntentServices(intent, PackageManager.GET_INTENT_FILTERS); return list.size() > 0; }
From source file:Main.java
public static boolean isIntentExist(Context context, Intent intent) { List<ResolveInfo> localList = context.getPackageManager().queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS); if ((localList != null) && (localList.size() > 0)) { return true; } else {//from w ww. j a va 2s. c om return false; } }
From source file:Main.java
/** * Utility method to check if a shortcut can be added to the homescreen. * @param context Context used to get the package manager. * @return if a shortcut can be added to the homescreen under the current profile. *//*from ww w.j a v a 2 s . co m*/ public static boolean isAddToHomeIntentSupported(Context context) { PackageManager pm = context.getPackageManager(); Intent i = new Intent(INSTALL_SHORTCUT); List<ResolveInfo> receivers = pm.queryBroadcastReceivers(i, PackageManager.GET_INTENT_FILTERS); return !receivers.isEmpty(); }
From source file:Main.java
/** * Utility method to check if a shortcut can be added to the home screen. * @param context Context used to get the package manager. * @return if a shortcut can be added to the home screen under the current profile. *//*w w w. j av a2 s . c o m*/ // TODO(crbug.com/635567): Fix this properly. @SuppressLint("WrongConstant") public static boolean isAddToHomeIntentSupported(Context context) { PackageManager pm = context.getPackageManager(); Intent i = new Intent(INSTALL_SHORTCUT); List<ResolveInfo> receivers = pm.queryBroadcastReceivers(i, PackageManager.GET_INTENT_FILTERS); return !receivers.isEmpty(); }
From source file:Main.java
public static boolean isIntentAvailable(final Context context, Intent intent) { final List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS); if (list != null && list.size() > 0) return true; return false; }
From source file:Main.java
public static boolean judge(Context paramContext, Intent paramIntent) { List<ResolveInfo> localList = paramContext.getPackageManager().queryIntentActivities(paramIntent, PackageManager.GET_INTENT_FILTERS); if ((localList != null) && (localList.size() > 0)) { return true; } else {/*from w w w .j a v a 2 s . c om*/ return false; } }
From source file:Main.java
@NonNull private static String prepareCheckReceiverReport(@NonNull final Context context, @Nullable final String exceptionMessage, @Nullable final String receiverName, @NonNull final Intent broadcastIntent) { final StringBuilder reportBuilder = new StringBuilder("checkReceiver error").append(LINE_SEPARATOR) .append("Exception message : ").append(exceptionMessage).append(LINE_SEPARATOR) .append("Expected receiverName : ").append(receiverName).append(LINE_SEPARATOR) .append("Intent action : ").append(broadcastIntent.getAction()); final PackageManager packageManager = context.getPackageManager(); final List<ResolveInfo> receivers = packageManager.queryBroadcastReceivers(broadcastIntent, PackageManager.GET_INTENT_FILTERS); if (receivers == null) { reportBuilder.append(LINE_SEPARATOR).append("queryBroadcastReceivers returns null"); } else if (receivers.isEmpty()) { reportBuilder.append(LINE_SEPARATOR).append("queryBroadcastReceivers returns empty list"); } else {//from w ww. j a va2s .co m reportBuilder.append(LINE_SEPARATOR) .append("queryBroadcastReceivers returns not empty list. List size : ").append(receivers.size()) .append(LINE_SEPARATOR).append("PackageName : ").append(context.getPackageName()); int emptyPackageNameCounter = 0; int emptyReceiverNameCounter = 0; for (ResolveInfo receiver : receivers) { if (TextUtils.isEmpty(receiver.activityInfo.packageName)) { ++emptyPackageNameCounter; } else if (receiver.activityInfo.packageName.equals(context.getPackageName())) { reportBuilder.append(LINE_SEPARATOR).append("Receiver with right package : ") .append(receiver.activityInfo.name); } if (TextUtils.isEmpty(receiver.activityInfo.name)) { ++emptyReceiverNameCounter; } else if (receiver.activityInfo.name.equals(receiverName)) { reportBuilder.append(LINE_SEPARATOR).append("Receiver with right name has package : ") .append(receiver.activityInfo.packageName); } } reportBuilder.append(LINE_SEPARATOR).append("Receivers with empty package name : ") .append(emptyPackageNameCounter).append(LINE_SEPARATOR).append("Receivers with empty name : ") .append(emptyReceiverNameCounter); } return reportBuilder.toString(); }
From source file:com.yalin.fidoclient.ui.fragment.AsmListFragment.java
private void initData() { Intent intent = ASMIntent.getASMIntent(); PackageManager pm = getActivity().getApplicationContext().getPackageManager(); List<ResolveInfo> infos = pm.queryIntentActivities(intent, PackageManager.GET_INTENT_FILTERS); if (infos != null && infos.size() > 0) { AsmListAdapter asmListAdapter = new AsmListAdapter(getActivity(), infos, this); rvAsmList.setAdapter(asmListAdapter); } else {/*from w w w . j a va 2s . com*/ tvAsmListPrompt.setText(R.string.no_asm); } }
From source file:com.owncloud.android.ui.helpers.FileOperationsHelper.java
public void openFile(OCFile file) { if (file != null) { String storagePath = file.getStoragePath(); Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW); intentForSavedMimeType.setDataAndType(file.getExposedFileUri(mFileActivity), file.getMimetype()); intentForSavedMimeType/*ww w . j a v a 2s. c om*/ .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent intentForGuessedMimeType = null; if (storagePath.lastIndexOf('.') >= 0) { String guessedMimeType = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1)); if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) { intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW); intentForGuessedMimeType.setDataAndType(file.getExposedFileUri(mFileActivity), guessedMimeType); intentForGuessedMimeType.setFlags( Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } } Intent openFileWithIntent; if (intentForGuessedMimeType != null) { openFileWithIntent = intentForGuessedMimeType; } else { openFileWithIntent = intentForSavedMimeType; } List<ResolveInfo> launchables = mFileActivity.getPackageManager() .queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS); if (launchables != null && launchables.size() > 0) { try { mFileActivity.startActivity(Intent.createChooser(openFileWithIntent, mFileActivity.getString(R.string.actionbar_open_with))); } catch (ActivityNotFoundException anfe) { mFileActivity .showSnackMessage(mFileActivity.getString(R.string.file_list_no_app_for_file_type)); } } else { mFileActivity.showSnackMessage(mFileActivity.getString(R.string.file_list_no_app_for_file_type)); } } else { Log_OC.e(TAG, "Trying to open a NULL OCFile"); } }
From source file:com.cerema.cloud2.files.FileOperationsHelper.java
public void openFile(OCFile file) { if (file != null) { String storagePath = file.getStoragePath(); String encodedStoragePath = WebdavUtils.encodePath(storagePath); Intent intentForSavedMimeType = new Intent(Intent.ACTION_VIEW); intentForSavedMimeType.setDataAndType(Uri.parse("file://" + encodedStoragePath), file.getMimetype()); intentForSavedMimeType/*from w w w.ja v a 2s. c o m*/ .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); Intent intentForGuessedMimeType = null; if (storagePath.lastIndexOf('.') >= 0) { String guessedMimeType = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(storagePath.substring(storagePath.lastIndexOf('.') + 1)); if (guessedMimeType != null && !guessedMimeType.equals(file.getMimetype())) { intentForGuessedMimeType = new Intent(Intent.ACTION_VIEW); intentForGuessedMimeType.setDataAndType(Uri.parse("file://" + encodedStoragePath), guessedMimeType); intentForGuessedMimeType.setFlags( Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION); } } Intent openFileWithIntent; if (intentForGuessedMimeType != null) { openFileWithIntent = intentForGuessedMimeType; } else { openFileWithIntent = intentForSavedMimeType; } List<ResolveInfo> launchables = mFileActivity.getPackageManager() .queryIntentActivities(openFileWithIntent, PackageManager.GET_INTENT_FILTERS); if (launchables != null && launchables.size() > 0) { try { mFileActivity.startActivity(Intent.createChooser(openFileWithIntent, mFileActivity.getString(R.string.actionbar_open_with))); } catch (ActivityNotFoundException anfe) { showNoAppForFileTypeToast(mFileActivity.getApplicationContext()); } } else { showNoAppForFileTypeToast(mFileActivity.getApplicationContext()); } } else { Log_OC.wtf(TAG, "Trying to open a NULL OCFile"); } }