Search in sources :

Example 11 with ResolveInfo

use of android.content.pm.ResolveInfo in project AndroidTraining by mixi-inc.

the class ActionMenu method addIntentOptions.

public int addIntentOptions(int groupId, int itemId, int order, ComponentName caller, Intent[] specifics, Intent intent, int flags, MenuItem[] outSpecificItems) {
    PackageManager pm = mContext.getPackageManager();
    final List<ResolveInfo> lri = pm.queryIntentActivityOptions(caller, specifics, intent, 0);
    final int N = lri != null ? lri.size() : 0;
    if ((flags & FLAG_APPEND_TO_GROUP) == 0) {
        removeGroup(groupId);
    }
    for (int i = 0; i < N; i++) {
        final ResolveInfo ri = lri.get(i);
        Intent rintent = new Intent(ri.specificIndex < 0 ? intent : specifics[ri.specificIndex]);
        rintent.setComponent(new ComponentName(ri.activityInfo.applicationInfo.packageName, ri.activityInfo.name));
        final MenuItem item = add(groupId, itemId, order, ri.loadLabel(pm)).setIcon(ri.loadIcon(pm)).setIntent(rintent);
        if (outSpecificItems != null && ri.specificIndex >= 0) {
            outSpecificItems[ri.specificIndex] = item;
        }
    }
    return N;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ComponentName(android.content.ComponentName) MenuItem(com.actionbarsherlock.view.MenuItem)

Example 12 with ResolveInfo

use of android.content.pm.ResolveInfo in project AndroidTraining by mixi-inc.

the class ActivityChooserView method updateAppearance.

/**
     * Updates the buttons state.
     */
private void updateAppearance() {
    // Expand overflow button.
    if (mAdapter.getCount() > 0) {
        mExpandActivityOverflowButton.setEnabled(true);
    } else {
        mExpandActivityOverflowButton.setEnabled(false);
    }
    // Default activity button.
    final int activityCount = mAdapter.getActivityCount();
    final int historySize = mAdapter.getHistorySize();
    if (activityCount > 0 && historySize > 0) {
        mDefaultActivityButton.setVisibility(VISIBLE);
        ResolveInfo activity = mAdapter.getDefaultActivity();
        PackageManager packageManager = mContext.getPackageManager();
        mDefaultActivityButtonImage.setImageDrawable(activity.loadIcon(packageManager));
        if (mDefaultActionButtonContentDescription != 0) {
            CharSequence label = activity.loadLabel(packageManager);
            String contentDescription = mContext.getString(mDefaultActionButtonContentDescription, label);
            mDefaultActivityButton.setContentDescription(contentDescription);
        }
        // Work-around for #415.
        mAdapter.setShowDefaultActivity(false, false);
    } else {
        mDefaultActivityButton.setVisibility(View.GONE);
    }
    // Activity chooser content.
    if (mDefaultActivityButton.getVisibility() == VISIBLE) {
        mActivityChooserContent.setBackgroundDrawable(mActivityChooserContentBackground);
    } else {
        mActivityChooserContent.setBackgroundDrawable(null);
        mActivityChooserContent.setPadding(0, 0, 0, 0);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager)

Example 13 with ResolveInfo

use of android.content.pm.ResolveInfo in project k-9 by k9mail.

the class RecipientPresenter method hasContactPicker.

/**
     * Does the device actually have a Contacts application suitable for
     * picking a contact. As hard as it is to believe, some vendors ship
     * without it.
     *
     * @return True, if the device supports picking contacts. False, otherwise.
     */
private boolean hasContactPicker() {
    if (hasContactPicker == null) {
        Contacts contacts = Contacts.getInstance(context);
        PackageManager packageManager = context.getPackageManager();
        List<ResolveInfo> resolveInfoList = packageManager.queryIntentActivities(contacts.contactPickerIntent(), 0);
        hasContactPicker = !resolveInfoList.isEmpty();
    }
    return hasContactPicker;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Contacts(com.fsck.k9.helper.Contacts) PackageManager(android.content.pm.PackageManager)

Example 14 with ResolveInfo

use of android.content.pm.ResolveInfo in project SeriesGuide by UweTrottmann.

the class IabHelper method startSetup.

/**
     * Starts the setup process. This will start up the setup process asynchronously. You will be
     * notified through the listener when the setup process is complete. This method is safe to call
     * from a UI thread.
     *
     * @param listener The listener to notify when the setup process is complete.
     */
public void startSetup(@NonNull final OnIabSetupFinishedListener listener) {
    if (context == null) {
        // helper should not have been disposed of already
        throwDisposed();
    }
    if (billingService != null || billingServiceConnection != null) {
        throw new IllegalStateException("IAB helper is already set up.");
    }
    // check if Google IAB service is available
    logDebug("Starting in-app billing setup.");
    Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
    serviceIntent.setPackage("com.android.vending");
    List<ResolveInfo> resolveInfos = context.getPackageManager().queryIntentServices(serviceIntent, 0);
    if (resolveInfos == null || resolveInfos.isEmpty()) {
        // billing service not available
        listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, "Billing service unavailable on device."));
        return;
    }
    billingServiceConnection = buildServiceConnection(listener);
    context.bindService(serviceIntent, billingServiceConnection, Context.BIND_AUTO_CREATE);
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 15 with ResolveInfo

use of android.content.pm.ResolveInfo in project SeriesGuide by UweTrottmann.

the class CustomTabsHelper method hasSpecializedHandlerIntents.

/**
     * Used to check whether there is a specialized handler for a given intent.
     *
     * @param intent The intent to check with.
     * @return Whether there is a specialized handler for the given intent.
     */
private static boolean hasSpecializedHandlerIntents(Context context, Intent intent) {
    try {
        PackageManager pm = context.getPackageManager();
        List<ResolveInfo> handlers = pm.queryIntentActivities(intent, PackageManager.GET_RESOLVED_FILTER);
        if (handlers == null || handlers.size() == 0) {
            return false;
        }
        for (ResolveInfo resolveInfo : handlers) {
            IntentFilter filter = resolveInfo.filter;
            if (filter == null) {
                continue;
            }
            if (filter.countDataAuthorities() == 0 || filter.countDataPaths() == 0) {
                continue;
            }
            if (resolveInfo.activityInfo == null) {
                continue;
            }
            return true;
        }
    } catch (RuntimeException e) {
        Log.e(TAG, "Runtime exception while getting specialized handlers");
    }
    return false;
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) IntentFilter(android.content.IntentFilter) PackageManager(android.content.pm.PackageManager)

Aggregations

ResolveInfo (android.content.pm.ResolveInfo)2316 Intent (android.content.Intent)1476 PackageManager (android.content.pm.PackageManager)875 ComponentName (android.content.ComponentName)637 ArrayList (java.util.ArrayList)515 ActivityInfo (android.content.pm.ActivityInfo)360 Test (org.junit.Test)282 ServiceInfo (android.content.pm.ServiceInfo)203 PendingIntent (android.app.PendingIntent)183 ApplicationInfo (android.content.pm.ApplicationInfo)178 RemoteException (android.os.RemoteException)170 Context (android.content.Context)101 Bundle (android.os.Bundle)97 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)81 IOException (java.io.IOException)78 PackageInfo (android.content.pm.PackageInfo)68 HashSet (java.util.HashSet)65 HashMap (java.util.HashMap)63 ActivityNotFoundException (android.content.ActivityNotFoundException)59 EphemeralResolveInfo (android.content.pm.EphemeralResolveInfo)58