Example usage for android.content.pm PackageManager queryIntentActivities

List of usage examples for android.content.pm PackageManager queryIntentActivities

Introduction

In this page you can find the example usage for android.content.pm PackageManager queryIntentActivities.

Prototype

public abstract List<ResolveInfo> queryIntentActivities(Intent intent, @ResolveInfoFlags int flags);

Source Link

Document

Retrieve all activities that can be performed for the given intent.

Usage

From source file:ja.keystore00.wallet.ui.RequestCoinsFragment.java

private boolean checkForLocalApp() {
    final Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("monacoin: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:ja.ohac.wallet.ui.RequestCoinsFragment.java

private boolean checkForLocalApp() {
    final Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("sakuracoin: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.android.tv.settings.MainFragment.java

private ResolveInfo systemIntentIsHandled(Intent intent) {
    if (intent == null) {
        return null;
    }/*from   w w  w  .  ja v  a2s.  co  m*/

    final PackageManager pm = getContext().getPackageManager();

    for (ResolveInfo info : pm.queryIntentActivities(intent, 0)) {
        if (info.activityInfo != null && info.activityInfo.enabled && (info.activityInfo.applicationInfo.flags
                & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM) {
            return info;
        }
    }
    return null;
}

From source file:org.familab.app.supportfiles.IntentIntegrator.java

private String findTargetAppPackage(Intent intent) {
    PackageManager pm = activity.getActivity().getPackageManager();
    List<ResolveInfo> availableApps = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    if (availableApps != null) {
        for (ResolveInfo availableApp : availableApps) {
            String packageName = availableApp.activityInfo.packageName;
            if (targetApplications.contains(packageName)) {
                return packageName;
            }/*from w  w  w  .  jav  a  2 s .  c o  m*/
        }
    }
    return null;
}

From source file:uk.co.tekkies.readings.fragment.PassageFragment.java

private boolean installMySword() {
    Analytics.UIClick(getActivity(), "opening-mysword-market");
    boolean installed = false;
    Uri marketUri = Uri.parse("market://details?id=" + MYSWORD_PACKAGE);
    Intent marketIntent = new Intent(Intent.ACTION_VIEW).setData(marketUri);
    PackageManager pm = getActivity().getPackageManager();
    List<ResolveInfo> list = pm.queryIntentActivities(marketIntent, PackageManager.MATCH_DEFAULT_ONLY);
    if (list.size() > 0)
        getActivity().startActivity(marketIntent);
    else {/*from   w w  w . jav a2s. co m*/
        Toast.makeText(getActivity(), R.string.sorry_no_market_installed, Toast.LENGTH_LONG).show();
    }
    return installed;
}

From source file:com.brq.wallet.activity.export.BackupToPdfActivity.java

private void grantPermissions(Intent intent, Uri uri) {
    // grant permissions for all apps that can handle given intent
    // if we know of any malicious app that tries to intercept this,
    // we could block it here based on packageName
    PackageManager packageManager = Preconditions.checkNotNull(getPackageManager());
    List<ResolveInfo> resInfoList = packageManager.queryIntentActivities(intent,
            PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo resolveInfo : resInfoList) {
        String packageName = resolveInfo.activityInfo.packageName;
        grantUriPermission(packageName, uri, Intent.FLAG_GRANT_READ_URI_PERMISSION);
    }//from  w w  w.j a  v  a 2 s. co  m
}

From source file:stepic.stepic.BaseMapsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutId());/* w  ww. j a v a 2  s.c o  m*/
    setUpMap();

    Intent camIntent = new Intent("android.media.action.IMAGE_CAPTURE");
    Intent gallIntent = new Intent(Intent.ACTION_GET_CONTENT);
    gallIntent.setType("image/*");
    info = new ArrayList<ResolveInfo>();
    yourIntentsList = new ArrayList<Intent>();
    PackageManager packageManager = BaseMapsActivity.this.getPackageManager();
    List<ResolveInfo> listCam = packageManager.queryIntentActivities(camIntent, 0);
    for (ResolveInfo res : listCam) {
        final Intent finalIntent = new Intent(camIntent);
        finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        yourIntentsList.add(finalIntent);
        info.add(res);
    }
    List<ResolveInfo> listGall = packageManager.queryIntentActivities(gallIntent, 0);
    for (ResolveInfo res : listGall) {
        final Intent finalIntent = new Intent(gallIntent);
        finalIntent.setComponent(new ComponentName(res.activityInfo.packageName, res.activityInfo.name));
        yourIntentsList.add(finalIntent);
        info.add(res);
    }

    //        android.support.v7.app.ActionBar actionBar = getSupportActionBar();
    //        actionBar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#330000ff")));
    //        actionBar.setStackedBackgroundDrawable(new ColorDrawable(Color.parseColor("#550000ff")));

    //Navigation Drawer
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    Drawable drawable = ContextCompat.getDrawable(getApplicationContext(), R.drawable.add);

    toolbar.setOverflowIcon(drawable);

    DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar,
            R.string.navigation_drawer_open, R.string.navigation_drawer_close);
    drawer.setDrawerListener(toggle);
    toggle.syncState();

    NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
    navigationView.setNavigationItemSelectedListener(this);

    mHandler = new Handler();

    Button add = (Button) findViewById(R.id.add);
    add.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent tmp = new Intent(Intent.ACTION_PICK);
            tmp.setType(android.provider.MediaStore.Images.Media.CONTENT_TYPE);
            startActivityForResult(tmp, PICK_FROM_ALBUM);

        }
    });

    //        runOnUiThread(new Runnable() {
    //            @Override
    //            public void run() {
    //                mProgressDialog = ProgressDialog.show(BaseMapsActivity.this, "", " .", true);
    //                mHandler.postDelayed(new Runnable() {
    //                    @Override
    //                    public void run() {
    //                        try {
    //                            if (mProgressDialog != null && mProgressDialog.isShowing()) {
    //                                mProgressDialog.dismiss();
    //                            }
    //                        } catch (Exception e) {
    //                            e.printStackTrace();
    //                        }
    //                    }
    //                }, 1000);
    //            }
    //
    //        });

}

From source file:com.ct.speech.HintReceiver.java

/**
 * Checks if a recognizer is present on this device
 *//*w  w w . jav  a 2  s  .  c o  m*/
private boolean isSpeechRecognizerPresent() {
    PackageManager pm = ((ContextWrapper) ctx).getPackageManager();
    List<ResolveInfo> activities = pm
            .queryIntentActivities(new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
    return !activities.isEmpty();
}

From source file:com.blu3f1re.reddwallet.ui.RequestCoinsFragment.java

private boolean checkForLocalApp() {
    final Intent intent = new Intent(Intent.ACTION_VIEW,
            Uri.parse("reddcoin: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.cyanogenmod.account.ui.SetupWizardActivity.java

private void disableSetupWizards(Intent intent) {
    final PackageManager pm = getPackageManager();
    final List<ResolveInfo> resolveInfos = pm.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo info : resolveInfos) {
        if (GOOGLE_SETUPWIZARD_PACKAGE.equals(info.activityInfo.packageName)) {
            final ComponentName componentName = new ComponentName(info.activityInfo.packageName,
                    info.activityInfo.name);
            pm.setComponentEnabledSetting(componentName, PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP);
        }//w  w w. j av  a  2  s .  com
    }
    pm.setComponentEnabledSetting(getComponentName(), PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
            PackageManager.DONT_KILL_APP);
}