PackageManager resolveActivity - 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 resolveActivity method.

This code example shows how to use the following methods:resolveActivity
	public static void launchMarketToInstallProScannerApp(Context ctx) {
		launchMarketToInstallApp(ctx, Scan.Pro.PACKAGE);
	} 
 
	private static boolean isIntentAvailable(Context ctx, String action) {
		Intent test = new Intent(action);
		return ctx.getPackageManager().resolveActivity(test, 0) != null;
	} 
 
	public static void launchMarketToInstallApp(Context ctx, String pkgName) {
		try { 
			Intent intent = new Intent(ACTION_VIEW, Uri.parse("market://details?id=" + pkgName));
			ctx.startActivity(intent);
		} catch (ActivityNotFoundException e) {
			Log.e(TAG, "Android Market aka Play Market not installed.", e);
			//Toast.makeText(ctx, R.string.error, Toast.LENGTH_SHORT).show(); 
		} 
	} 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDataAndType, resolveActivity
    } 
 
    // @return a ResolveInfo instance for the mime type or null if the type is 
    // not handled by any activity. 
    private ResolveInfo resolveMime(String mime) {
        Intent viewIntent = new Intent(Intent.ACTION_VIEW);
        Uri uri = Uri.fromParts("file", MP3_FILE, null);
 
        viewIntent.setDataAndType(uri, mime);
        return mContext.getPackageManager().resolveActivity(
                viewIntent, PackageManager.MATCH_DEFAULT_ONLY);
    } 
 
    // Helper method to check the media playback activity handles the given mime type. 
    // @param mime type to test for 
    private void assertMediaPlaybackActivityHandles(String mime) throws Exception {
        ResolveInfo ri = resolveMime(mime);
 
        assertNotNull(ri);
    } 
8
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:setDataAndType, resolveActivity
        if (contentDisposition == null
                || !contentDisposition.regionMatches(
                        true, 0, "attachment", 0, 10)) { 
            // query the package manager to see if there's a registered handler 
            //     that matches. 
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setDataAndType(Uri.parse(url), mimetype);
            ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
                    PackageManager.MATCH_DEFAULT_ONLY);
            if (info != null) {
                ComponentName myName = activity.getComponentName();
                // If we resolved to ourselves, we don't want to attempt to 
                // load the url only to try and download it again. 
                if (!myName.getPackageName().equals(
                        info.activityInfo.packageName)
                        || !myName.getClassName().equals(
                                info.activityInfo.name)) {
                    // someone (other than us) knows how to handle this mime 
                    // type with this scheme, don't download. 
                    try { 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
        } 
        return isVoiceSearchAvailable(); 
    } 
 
    private boolean isVoiceSearchAvailable() { 
        Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
        ResolveInfo ri = mContext.getPackageManager().
                resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
        return ri != null;
    } 
 
    public Intent getSuggestionIntent(SuggestionCursor cursor, int position,
            Bundle appSearchData) {
        cursor.moveTo(position);
        Source source = cursor.getSuggestionSource();
        String action = cursor.getSuggestionIntentAction();
        // use specific action if supplied, or default action if supplied, or fixed default 
        if (action == null) {
            action = source.getDefaultIntentAction();
            if (action == null) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
            assertNotNull(intent);
            assertTrue(intent.getAction().equals(Intent.ACTION_WEB_SEARCH)
                    || intent.getAction().equals(SearchManager.INTENT_ACTION_GLOBAL_SEARCH));
            switch (mSearchablesMode) {
            case SEARCHABLES_PASSTHROUGH:
                return mRealPackageManager.resolveActivity(intent, flags);
            case SEARCHABLES_MOCK_ZERO:
                return null; 
            default: 
                throw new UnsupportedOperationException();
            } 
        } 
 
        /** 
         * Retrieve an XML file from a package.  This is a low-level API used to 
         * retrieve XML meta data. 
         *  
         * @param packageName The name of the package that this xml is coming from. 
         * Can not be null. 
         * @param resid The resource identifier of the desired xml.  Can not be 0. 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
 
		final Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=de.schildbach.wallet"));
		final Intent binaryIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://code.google.com/p/bitcoin-wallet/downloads/list"));
 
		final PackageManager pm = context.getPackageManager();
		if (pm.resolveActivity(marketIntent, 0) != null)
			context.startActivity(marketIntent);
		else if (pm.resolveActivity(binaryIntent, 0) != null)
			context.startActivity(binaryIntent);
		// else out of luck 
	} 
 
	private static final String INTENT_EXTRA_TRANSACTION_HASH_OLD = "transaction_id";
} 
5
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
            assertNotNull(intent);
            assertTrue(intent.getAction().equals(Intent.ACTION_WEB_SEARCH)
                    || intent.getAction().equals(SearchManager.INTENT_ACTION_GLOBAL_SEARCH));
            switch (mSearchablesMode) {
            case SEARCHABLES_PASSTHROUGH:
                return mRealPackageManager.resolveActivity(intent, flags);
            case SEARCHABLES_MOCK_ZERO:
                return null; 
            default: 
                throw new UnsupportedOperationException();
            } 
        } 
 
        /** 
         * Retrieve an XML file from a package.  This is a low-level API used to 
         * retrieve XML meta data. 
         *  
         * @param packageName The name of the package that this xml is coming from. 
         * Can not be null. 
         * @param resid The resource identifier of the desired xml.  Can not be 0. 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
        return wrapped.getInstalledApplications(flags);
    } 
 
    @Override 
    public ResolveInfo resolveActivity(Intent intent, int flags) {
        return wrapped.resolveActivity(intent, flags);
    } 
 
    @Override 
    public List<ResolveInfo> queryIntentActivities(Intent intent, int flags) {
        return wrapped.queryIntentActivities(intent, flags);
    } 
 
    @Override 
    public List<ResolveInfo> queryIntentActivityOptions(ComponentName caller,
            Intent[] specifics, Intent intent, int flags) {
        return wrapped.queryIntentActivityOptions(caller, specifics, intent, flags);
    } 
 
    @Override 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
        sIsPhone = (telephonyManager.getPhoneType() != TelephonyManager.PHONE_TYPE_NONE);
        //sIsSipPhone = sIsPhone && SipManager.isVoipSupported(context); 
        Intent pIntent = getPriviledgedIntent("123");
        callIntents = getPossibleActivities(context, pIntent);
        PackageManager pm = context.getPackageManager();
        defaultCallIntent = pm.resolveActivity(pIntent, PackageManager.MATCH_DEFAULT_ONLY);
         
        sIsInitialized = true;
    } 
     
    public static void deinit() { 
        sIsInitialized = false;
    } 
 
    /** 
     * Returns true if this device can be used to make sip calls 
     */ 
    /* 
    public static boolean isSipPhone(Context context) { 
        if (!sIsInitialized) initialize(context); 
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:resolveActivity
            assertNotNull(intent);
            assertTrue(intent.getAction().equals(Intent.ACTION_WEB_SEARCH)
                    || intent.getAction().equals(SearchManager.INTENT_ACTION_GLOBAL_SEARCH));
            switch (mSearchablesMode) {
            case SEARCHABLES_PASSTHROUGH:
                return mRealPackageManager.resolveActivity(intent, flags);
            case SEARCHABLES_MOCK_ZERO:
                return null; 
            default: 
                throw new UnsupportedOperationException();
            } 
        } 
 
        /** 
         * Retrieve an XML file from a package.  This is a low-level API used to 
         * retrieve XML meta data. 
         *  
         * @param packageName The name of the package that this xml is coming from. 
         * Can not be null. 
         * @param resid The resource identifier of the desired xml.  Can not be 0. 
4
CodeRank
Experience pair programming with AI  Get Codota for Java

Related PackageManager resolveActivity Questions & Answers:

resolveActivity Method Overview
Determine the best action to perform for a given Intent.
See Code Examples for other Android PackageManager Methods: