Search in sources :

Example 6 with PackageManager

use of android.content.pm.PackageManager in project coinbase-bitmonet-sdk by coinbase.

the class CoinbasePaymentProcessor method checkWalletAndSendMoney.

public void checkWalletAndSendMoney(Context context, String item, double amount) {
    // Check if there is a valid receiving address
    if (UserProfileSettings.getInstance().retrieveMerchantReceivingAddress() == null) {
        ((BitmonetPaymentStatusListener) context).paymentFailure(getErrorsAarrayFromString(Constants.ERROR_INVALID_RECEIVING_ADDRESS));
        return;
    }
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(URLUtils.constructBitcoinIntentURL(amount)));
    // Check if there a wallet to handle the intent
    PackageManager manager = context.getPackageManager();
    List<ResolveInfo> activities = manager.queryIntentActivities(intent, 0);
    if (activities.size() > 0) {
        context.startActivity(intent);
    } else {
        showModalAndTransferMoney(context, item, amount);
    }
}
Also used : ResolveInfo(android.content.pm.ResolveInfo) BitmonetPaymentStatusListener(com.bitmonet.BitmonetPaymentStatusListener) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent)

Example 7 with PackageManager

use of android.content.pm.PackageManager in project Launcher3 by chislon.

the class LauncherModel method getShortcutInfo.

/**
     * Make an ShortcutInfo object for a shortcut that isn't an application.
     */
private ShortcutInfo getShortcutInfo(Cursor c, Context context, int iconTypeIndex, int iconPackageIndex, int iconResourceIndex, int iconIndex, int titleIndex) {
    Bitmap icon = null;
    final ShortcutInfo info = new ShortcutInfo();
    info.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
    // TODO: If there's an explicit component and we can't install that, delete it.
    info.title = c.getString(titleIndex);
    int iconType = c.getInt(iconTypeIndex);
    switch(iconType) {
        case LauncherSettings.Favorites.ICON_TYPE_RESOURCE:
            String packageName = c.getString(iconPackageIndex);
            String resourceName = c.getString(iconResourceIndex);
            PackageManager packageManager = context.getPackageManager();
            info.customIcon = false;
            // the resource
            try {
                Resources resources = packageManager.getResourcesForApplication(packageName);
                if (resources != null) {
                    final int id = resources.getIdentifier(resourceName, null, null);
                    icon = Utilities.createIconBitmap(mIconCache.getFullResIcon(resources, id), context);
                }
            } catch (Exception e) {
            // drop this.  we have other places to look for icons
            }
            // the db
            if (icon == null) {
                icon = getIconFromCursor(c, iconIndex, context);
            }
            // the fallback icon
            if (icon == null) {
                icon = getFallbackIcon();
                info.usingFallbackIcon = true;
            }
            break;
        case LauncherSettings.Favorites.ICON_TYPE_BITMAP:
            icon = getIconFromCursor(c, iconIndex, context);
            if (icon == null) {
                icon = getFallbackIcon();
                info.customIcon = false;
                info.usingFallbackIcon = true;
            } else {
                info.customIcon = true;
            }
            break;
        default:
            icon = getFallbackIcon();
            info.usingFallbackIcon = true;
            info.customIcon = false;
            break;
    }
    info.setIcon(icon);
    return info;
}
Also used : Bitmap(android.graphics.Bitmap) PackageManager(android.content.pm.PackageManager) Resources(android.content.res.Resources) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException) URISyntaxException(java.net.URISyntaxException) RemoteException(android.os.RemoteException)

Example 8 with PackageManager

use of android.content.pm.PackageManager in project Launcher3 by chislon.

the class LauncherModel method resolveWidgetsForMimeType.

/**
     * Returns a list of all the widgets that can handle configuration with a particular mimeType.
     */
List<WidgetMimeTypeHandlerData> resolveWidgetsForMimeType(Context context, String mimeType) {
    final PackageManager packageManager = context.getPackageManager();
    final List<WidgetMimeTypeHandlerData> supportedConfigurationActivities = new ArrayList<WidgetMimeTypeHandlerData>();
    final Intent supportsIntent = new Intent(InstallWidgetReceiver.ACTION_SUPPORTS_CLIPDATA_MIMETYPE);
    supportsIntent.setType(mimeType);
    // Create a set of widget configuration components that we can test against
    final List<AppWidgetProviderInfo> widgets = AppWidgetManager.getInstance(context).getInstalledProviders();
    final HashMap<ComponentName, AppWidgetProviderInfo> configurationComponentToWidget = new HashMap<ComponentName, AppWidgetProviderInfo>();
    for (AppWidgetProviderInfo info : widgets) {
        configurationComponentToWidget.put(info.configure, info);
    }
    // Run through each of the intents that can handle this type of clip data, and cross
    // reference them with the components that are actual configuration components
    final List<ResolveInfo> activities = packageManager.queryIntentActivities(supportsIntent, PackageManager.MATCH_DEFAULT_ONLY);
    for (ResolveInfo info : activities) {
        final ActivityInfo activityInfo = info.activityInfo;
        final ComponentName infoComponent = new ComponentName(activityInfo.packageName, activityInfo.name);
        if (configurationComponentToWidget.containsKey(infoComponent)) {
            supportedConfigurationActivities.add(new InstallWidgetReceiver.WidgetMimeTypeHandlerData(info, configurationComponentToWidget.get(infoComponent)));
        }
    }
    return supportedConfigurationActivities;
}
Also used : ActivityInfo(android.content.pm.ActivityInfo) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) WidgetMimeTypeHandlerData(com.android.launcher3.InstallWidgetReceiver.WidgetMimeTypeHandlerData) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) AppWidgetProviderInfo(android.appwidget.AppWidgetProviderInfo) WidgetMimeTypeHandlerData(com.android.launcher3.InstallWidgetReceiver.WidgetMimeTypeHandlerData)

Example 9 with PackageManager

use of android.content.pm.PackageManager in project cw-omnibus by commonsguy.

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 10 with PackageManager

use of android.content.pm.PackageManager in project PlayerHater by chrisrhoden.

the class StatelyPlayer method setWakeLock.

private void setWakeLock(Context context) {
    PackageManager pm = context.getPackageManager();
    String packageName = context.getPackageName();
    if (pm.checkPermission(PERMISSION, packageName) == GRANTED) {
        mMediaPlayer.setWakeMode(context, WAKE_LOCK);
    } else {
        Log.d("You need to request wake lock permission to enable wake locking during playback.");
    }
}
Also used : PackageManager(android.content.pm.PackageManager)

Aggregations

PackageManager (android.content.pm.PackageManager)1429 Intent (android.content.Intent)483 ResolveInfo (android.content.pm.ResolveInfo)449 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)345 ApplicationInfo (android.content.pm.ApplicationInfo)249 PackageInfo (android.content.pm.PackageInfo)248 ComponentName (android.content.ComponentName)239 ArrayList (java.util.ArrayList)156 ActivityInfo (android.content.pm.ActivityInfo)135 IOException (java.io.IOException)126 RemoteException (android.os.RemoteException)105 IPackageManager (android.content.pm.IPackageManager)93 Drawable (android.graphics.drawable.Drawable)93 Resources (android.content.res.Resources)90 PendingIntent (android.app.PendingIntent)71 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Context (android.content.Context)63 Bundle (android.os.Bundle)60 HashMap (java.util.HashMap)53 ServiceInfo (android.content.pm.ServiceInfo)46