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