PackageManager queryIntentActivities - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager queryIntentActivities method.

This code example shows how to use the following methods:setType, queryIntentActivities
     * @param mimeType 
     *            the MIME type of the content (may be null) 
     * @return true if there are apps which will respond to this action/data 
     */ 
    public static boolean isIntentAvailable(Context context, String action, Uri uri, String mimeType) {
        final Intent intent = (uri != null) ? new Intent(action, uri) : new Intent(action);
        if (mimeType != null) {
            intent.setType(mimeType);
        } 
        List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return !list.isEmpty();
    } 
 
    /** 
     * Checks whether there are applications installed which are able to handle the given 
     * action/type. 
     *  
     * @param context 
     *            the current context 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:queryIntentActivities
     * 
     * @return whether this phone supports voiceinput 
     */ 
    public static boolean voiceInputAvailable(Context context) {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> activities = pm.queryIntentActivities(
                new Intent(RecognizerIntent.ACTION_RECOGNIZE_SPEECH), 0);
        return (activities.size() != 0);
    } 
 
    private VoiceRecognizer() { 
        // 
    } 
 
    private static VoiceRecognizer instance = null;
 
    public static VoiceRecognizer instantiateVoiceRecognizer(Context context, RecognizerApiListener listener, ImageButton voiceAddButton) {
        synchronized(VoiceRecognizer.class) { 
            if (instance == null)
                instance = new VoiceRecognizer();
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setType, queryIntentActivities
     * @param mimeType 
     *            the MIME type of the content (may be null) 
     * @return true if there are apps which will respond to this action/data 
     */ 
    public static boolean isIntentAvailable(Context context, String action, Uri uri, String mimeType) {
        final Intent intent = (uri != null) ? new Intent(action, uri) : new Intent(action);
        if (mimeType != null) {
            intent.setType(mimeType);
        } 
        List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        return !list.isEmpty();
    } 
 
    /** 
     * Checks whether there are applications installed which are able to handle the given 
     * action/type. 
     *  
     * @param context 
     *            the current context 
8
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:queryIntentActivities
	 *         responded to, false otherwise. 
	 */ 
	public static boolean isIntentAvailable(Context context, String action) {
	    final PackageManager packageManager = context.getPackageManager();
	    final Intent intent = new Intent(action);
	    List<ResolveInfo> list =
	            packageManager.queryIntentActivities(intent,
	                    PackageManager.MATCH_DEFAULT_ONLY);
	    return list.size() > 0;
	} 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCategory, queryIntentActivities
    } 
 
    private List<ResolveInfo> mApps;
 
    private void loadApps() { 
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
 
        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    } 
 
    public class AppsAdapter extends BaseAdapter {
        public AppsAdapter() { 
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i;
 
            if (convertView == null) {
                i = new ImageView(Grid1.this);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addFlags, setPackage, queryIntentActivities
This code example shows how to use the following methods:addCategory, queryIntentActivities
    } 
 
    private List<ResolveInfo> mApps;
 
    private void loadApps() { 
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
 
        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    } 
 
    public class AppsAdapter extends BaseAdapter {
        public AppsAdapter() { 
        } 
 
        public View getView(int position, View convertView, ViewGroup parent) {
            CheckableLayout l;
            ImageView i;
 
            if (convertView == null) {
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:queryIntentActivities, loadIcon
        return System.currentTimeMillis();
    } 
 
    public static Drawable getIconForIntent(final Context context, Intent i) {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> infos = pm.queryIntentActivities(i, PackageManager.MATCH_DEFAULT_ONLY);
        if (infos.size() > 0) {
            return infos.get(0).loadIcon(pm);
        } 
        return null; 
    } 
 
} 
6
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setData, queryIntentActivities
		final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
		context.startActivity(intent);
	} 
	 
	public static void openURI(final Context context, final String uri, final String alternateUri) {
		Intent intent = new Intent(Intent.ACTION_VIEW);
		intent.setData(Uri.parse(uri));
		List<ResolveInfo> list = context.getPackageManager().queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
		if (list != null && list.size() > 0) {
			context.startActivity(intent);
		} else { 
			if (alternateUri != null) {
				intent = new Intent(Intent.ACTION_VIEW);
				intent.setData(Uri.parse(alternateUri));
				context.startActivity(intent);
			} 
		} 
	} 
} 
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:addCategory, queryIntentActivities
    } 
 
    private List<ResolveInfo> mApps;
 
    private void loadApps() { 
        Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
        mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
 
        mApps = getPackageManager().queryIntentActivities(mainIntent, 0);
    } 
 
    public class AppsAdapter extends BaseAdapter {
        public View getView(int position, View convertView, ViewGroup parent) {
            ImageView i = new ImageView(LayoutAnimation1.this);
 
            ResolveInfo info = mApps.get(position % mApps.size());
 
            i.setImageDrawable(info.activityInfo.loadIcon(getPackageManager()));
            i.setScaleType(ImageView.ScaleType.FIT_CENTER);
            final int w = (int) (36 * getResources().getDisplayMetrics().density + 0.5f);
7
CodeRank
Connect your IDE to all the code out there  Get Codota for Java

Related PackageManager queryIntentActivities Questions & Answers:

queryIntentActivities Method Overview
Retrieve all activities that can be performed for the given intent.
See Code Examples for other Android PackageManager Methods: