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);
}
}
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;
}
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;
}
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);
}
}
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.");
}
}
Aggregations