List of usage examples for android.content.pm PackageManager queryIntentActivities
public abstract List<ResolveInfo> queryIntentActivities(Intent intent, @ResolveInfoFlags int flags);
From source file:com.dopecoin.wallet.ui.RequestCoinsFragment.java
private boolean checkForLocalApp() { final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("dopecoin:DEwTHxztkSDUJEMywbPk5zVUGrupaNRqEy")); //Just for testing; will never be fired. PackageManager manager = getActivity().getPackageManager(); List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0); return infos.size() > 0 ? true : false; }
From source file:in.leafco.wallet.ui.RequestCoinsFragment.java
private boolean checkForLocalApp() { final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("leafcoin:DEwTHxztkSDUJEMywbPk5zVUGrupaNRqEy")); //Just for testing; will never be fired. PackageManager manager = getActivity().getPackageManager(); List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0); return infos.size() > 0 ? true : false; }
From source file:cc.mintcoin.wallet.ui.RequestCoinsFragment.java
private boolean checkForLocalApp() { final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mintcoin:DEwTHxztkSDUJEMywbPk5zVUGrupaNRqEy")); //Just for testing; will never be fired. PackageManager manager = getActivity().getPackageManager(); List<ResolveInfo> infos = manager.queryIntentActivities(intent, 0); return infos.size() > 0 ? true : false; }
From source file:com.collecdoo.fragment.main.RegisterDriverPhotoFragment.java
private void openImageIntent(int uploadIndex) { //EasyImage.openChooserWithGallery(this,"Please choose",0); File imageFile = ImageHelper.createFile(context, "extend_picture.jpg"); String cameraImageFullPath = imageFile.getAbsolutePath(); cameraOutputFileUri = Uri.fromFile(imageFile); // Camera./* w w w .j a v a 2 s . c om*/ final List<Intent> cameraIntents = new ArrayList<Intent>(); final Intent captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); final PackageManager packageManager = context.getPackageManager(); final List<ResolveInfo> listCam = packageManager.queryIntentActivities(captureIntent, 0); for (ResolveInfo res : listCam) { final String packageName = res.activityInfo.packageName; final Intent intent = new Intent(captureIntent); intent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name)); intent.setPackage(packageName); intent.putExtra(MediaStore.EXTRA_OUTPUT, cameraOutputFileUri); cameraIntents.add(intent); } // Filesystem. final Intent galleryIntent = new Intent(); galleryIntent.setType("image/*"); galleryIntent.setAction(Intent.ACTION_PICK); // Chooser of filesystem options. final Intent chooserIntent = Intent.createChooser(galleryIntent, "Select Source"); // Add the camera options. chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, cameraIntents.toArray(new Parcelable[] {})); startActivityForResult(chooserIntent, uploadIndex); }
From source file:com.rp.podemu.SettingsActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_settings); sharedPref = this.getSharedPreferences("PODEMU_PREFS", Context.MODE_PRIVATE); //String[] controlledApp = new String[appsRunning.size()]; //Drawable[] icons = new Drawable[appsRunning.size()]; //pm.getApplicationInfo(r.baseActivity.getPackageName(), PackageManager.GET_META_DATA); //Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //startActivity(intent); Intent intent = new Intent(Intent.ACTION_MAIN, null); intent.addCategory(Intent.CATEGORY_APP_MUSIC); PackageManager pm = getPackageManager(); String text = ""; List<ResolveInfo> packages = pm.queryIntentActivities(intent, 0); //get a list of installed apps. //List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA); //using hashset so that there will be no duplicate packages, //if no duplicate packages then there will be no duplicate apps HashSet<String> packageNames = new HashSet<String>(0); appInfos = new ArrayList<ApplicationInfo>(0); //getting package names and adding them to the hashset for (ResolveInfo resolveInfo : packages) { packageNames.add(resolveInfo.activityInfo.packageName); }//from w w w. j a v a 2 s . co m // used just for tests /* ApplicationInfo dummyApp = new ApplicationInfo(); dummyApp.name="select application"; dummyApp.processName="dummy"; appInfos.add(dummyApp); */ for (String packageName : PodEmuIntentFilter.getAppList()) { try { appInfos.add(pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)); } catch (PackageManager.NameNotFoundException e) { //Do Nothing } } //now we have unique packages in the hashset, so get their application infos //and add them to the arraylist for (String packageName : packageNames) { try { appInfos.add(pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA)); } catch (PackageManager.NameNotFoundException e) { //Do Nothing } } text += "Apps count: " + appInfos.size() + "\n"; for (ApplicationInfo appInfo : appInfos) { //if (packageInfo.) { appInfo.name = (String) appInfo.loadLabel(pm); text += appInfo.loadLabel(pm) + "\n"; //text += packageInfo. //text += "\n"; } } //TextView textView = (TextView) findViewById(R.id.ctrlAppTitle); //textView.setText(text); //LauncherApps launcherApps=new LauncherApps(); //List<LauncherActivityInfo> activities=launcherApps.getActivityList(null, android.os.Process.myUserHandle()); //List<LauncherActivityInfo> activities=LauncherApps().getActivityList(null, android.os.Process.myUserHandle()); baudRateList.add(9600); baudRateList.add(14400); baudRateList.add(19200); baudRateList.add(28800); baudRateList.add(38400); baudRateList.add(56000); baudRateList.add(57600); baudRateList.add(115200); try { PackageInfo pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); String version = pInfo.versionName; TextView versionHint = (TextView) findViewById(R.id.versionHint); versionHint.setText(getResources().getString(R.string.version_hint) + version); } catch (PackageManager.NameNotFoundException e) { // do nothing } }
From source file:texus.autozoneuaenew.fragments.FragmentProductDetails.java
public void showPdf() { File file = new File(ApplicationClass.PDF_FOLDER + File.separator + pdfFileName); PackageManager packageManager = ApplicationClass.getInstance().getPackageManager(); Intent testIntent = new Intent(Intent.ACTION_VIEW); testIntent.setType("application/pdf"); List list = packageManager.queryIntentActivities(testIntent, PackageManager.MATCH_DEFAULT_ONLY); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); Uri uri = Uri.fromFile(file);//w w w .j a v a2 s .c o m intent.setDataAndType(uri, "application/pdf"); startActivity(intent); }
From source file:widgets.PageWidget.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); wv = (WebView) super.getActivity().findViewById(activity.getActId()); // get the location data String url = course.getLocation() + activity.getLocation(prefs.getString(super.getActivity().getString(R.string.prefs_language), Locale.getDefault().getLanguage())); try {//from w w w. j a va 2s .c o m wv.loadDataWithBaseURL("file://" + course.getLocation() + "/", FileUtils.readFile(url), "text/html", "utf-8", null); } catch (IOException e) { wv.loadUrl("file://" + url); } // set up the page to intercept videos wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains("/video/")) { Log.d(TAG, "Intercepting click on video url: " + url); // extract video name from url int startPos = url.indexOf("/video/") + 7; mediaFileName = url.substring(startPos, url.length()); // check video file exists boolean exists = FileUtils.mediaFileExists(mediaFileName); if (!exists) { Toast.makeText(PageWidget.super.getActivity(), PageWidget.super.getActivity() .getString(R.string.error_media_not_found, mediaFileName), Toast.LENGTH_LONG) .show(); return true; } String mimeType = FileUtils.getMimeType(MobileLearning.MEDIA_PATH + mediaFileName); if (!FileUtils.supportedMediafileType(mimeType)) { Toast.makeText(PageWidget.super.getActivity(), PageWidget.super.getActivity() .getString(R.string.error_media_unsupported, mediaFileName), Toast.LENGTH_LONG) .show(); return true; } // check user has app installed to play the video // launch intent to play video Intent intent = new Intent(android.content.Intent.ACTION_VIEW); Uri data = Uri.parse(MobileLearning.MEDIA_PATH + mediaFileName); intent.setDataAndType(data, "video/mp4"); PackageManager pm = PageWidget.super.getActivity().getPackageManager(); List<ResolveInfo> infos = pm.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER); boolean appFound = false; for (ResolveInfo info : infos) { IntentFilter filter = info.filter; if (filter != null && filter.hasAction(Intent.ACTION_VIEW)) { // Found an app with the right intent/filter appFound = true; } } if (!appFound) { Toast.makeText(PageWidget.super.getActivity(), PageWidget.super.getActivity().getString(R.string.error_media_app_not_found), Toast.LENGTH_LONG).show(); return true; } PageWidget.this.mediaPlaying = true; PageWidget.this.mediaStartTimeStamp = System.currentTimeMillis() / 1000; PageWidget.super.getActivity().startActivity(intent); return true; } else { Intent intent = new Intent(Intent.ACTION_VIEW); Uri data = Uri.parse(url); intent.setData(data); PageWidget.super.getActivity().startActivity(intent); // launch action in mobile browser - not the webview // return true so doesn't follow link within webview return true; } } }); }
From source file:org.totschnig.myexpenses.util.Utils.java
/** * Indicates whether the specified action can be used as an intent. This * method queries the package manager for installed packages that can respond * to an intent with the specified action. If no suitable package is found, * this method returns false./*w w w . j a v a2 s . c o m*/ * * From * http://android-developers.blogspot.fr/2009/01/can-i-use-this-intent.html * * @param context * The application's environment. * @param intent * The Intent action to check for availability. * * @return True if an Intent with the specified action can be sent and * responded to, false otherwise. */ public static boolean isIntentAvailable(Context context, Intent intent) { final PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return !list.isEmpty(); }
From source file:com.e2g.ecocicle.barcode.IntentIntegrator.java
private String findTargetAppPackage(Intent intent) { PackageManager pm = activity.getPackageManager(); List<ResolveInfo> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); if (availableApps != null) { for (String targetApp : targetApplications) { if (contains(availableApps, targetApp)) { return targetApp; }//from w w w. ja v a 2 s. co m } } return null; }
From source file:th.in.ffc.app.FFCFragmentActivity.java
@Override public void startActivity(Intent intent) { intent.putExtra(EXTRA_PCUCODE, this.extra_pcucode); intent.putExtra(EXTRA_USER, this.extra_user); PackageManager pm = getPackageManager(); List<ResolveInfo> IntentList = pm.queryIntentActivities(intent, 0); if (IntentList.size() == 0) { Toast.makeText(this, "Not Found Activity!", Toast.LENGTH_SHORT).show(); } else {//w w w . j ava2s . c o m super.startActivity(intent); overridePendingTransition(R.anim.slide_in, R.anim.slide_out); } }