use of android.content.pm.ResolveInfo in project HoloEverywhere by Prototik.
the class ResolverActivity method onIntentSelected.
@SuppressWarnings("deprecation")
protected void onIntentSelected(ResolveInfo ri, Intent intent, boolean alwaysCheck) {
if (alwaysCheck) {
IntentFilter filter = new IntentFilter();
if (intent.getAction() != null) {
filter.addAction(intent.getAction());
}
Set<String> categories = intent.getCategories();
if (categories != null) {
for (String cat : categories) {
filter.addCategory(cat);
}
}
filter.addCategory(Intent.CATEGORY_DEFAULT);
int cat = ri.match & IntentFilter.MATCH_CATEGORY_MASK;
Uri data = intent.getData();
if (cat == IntentFilter.MATCH_CATEGORY_TYPE) {
String mimeType = intent.resolveType(this);
if (mimeType != null) {
try {
filter.addDataType(mimeType);
} catch (IntentFilter.MalformedMimeTypeException e) {
Log.w("ResolverActivity", e);
filter = null;
}
}
}
if (data != null && data.getScheme() != null) {
if (cat != IntentFilter.MATCH_CATEGORY_TYPE || !"file".equals(data.getScheme()) && !"content".equals(data.getScheme())) {
filter.addDataScheme(data.getScheme());
Iterator<IntentFilter.AuthorityEntry> aIt = ri.filter.authoritiesIterator();
if (aIt != null) {
while (aIt.hasNext()) {
IntentFilter.AuthorityEntry a = aIt.next();
if (a.match(data) >= 0) {
int port = a.getPort();
filter.addDataAuthority(a.getHost(), port >= 0 ? Integer.toString(port) : null);
break;
}
}
}
Iterator<PatternMatcher> pIt = ri.filter.pathsIterator();
if (pIt != null) {
String path = data.getPath();
while (path != null && pIt.hasNext()) {
PatternMatcher p = pIt.next();
if (p.match(path)) {
filter.addDataPath(p.getPath(), p.getType());
break;
}
}
}
}
}
if (filter != null) {
final int N = mAdapter.mList.size();
ComponentName[] set = new ComponentName[N];
int bestMatch = 0;
for (int i = 0; i < N; i++) {
ResolveInfo r = mAdapter.mList.get(i).ri;
set[i] = new ComponentName(r.activityInfo.packageName, r.activityInfo.name);
if (r.match > bestMatch) {
bestMatch = r.match;
}
}
try {
getPackageManager().addPreferredActivity(filter, bestMatch, set, intent.getComponent());
} catch (Exception e) {
e.printStackTrace();
}
}
}
if (intent != null) {
startActivity(intent);
}
}
use of android.content.pm.ResolveInfo in project HoloEverywhere by Prototik.
the class ActivityChooserModel method loadActivitiesIfNeeded.
/**
* Loads the activities for the current intent if needed which is
* if they are not already loaded for the current intent.
*
* @return Whether loading was performed.
*/
private boolean loadActivitiesIfNeeded() {
if (mReloadActivities && mIntent != null) {
mReloadActivities = false;
mActivities.clear();
List<ResolveInfo> resolveInfos = mContext.getPackageManager().queryIntentActivities(mIntent, 0);
final int resolveInfoCount = resolveInfos.size();
for (int i = 0; i < resolveInfoCount; i++) {
ResolveInfo resolveInfo = resolveInfos.get(i);
mActivities.add(new ActivityResolveInfo(resolveInfo));
}
return true;
}
return false;
}
use of android.content.pm.ResolveInfo in project Anki-Android by Ramblurr.
the class Utils method isIntentAvailable.
public static boolean isIntentAvailable(Context context, String action, ComponentName componentName) {
final PackageManager packageManager = context.getPackageManager();
final Intent intent = new Intent(action);
intent.setComponent(componentName);
List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
return list.size() > 0;
}
use of android.content.pm.ResolveInfo in project Reader by TheKeeperOfPie.
the class FragmentWeb method showExternalLaunchDialog.
private void showExternalLaunchDialog(final String data, final List<ResolveInfo> listResolveInfo, PackageManager packageManager) {
CharSequence[] titles = new CharSequence[1 + listResolveInfo.size()];
titles[0] = getString(R.string.app_name);
for (int index = 1; index < titles.length; index++) {
titles[index] = listResolveInfo.get(index - 1).loadLabel(packageManager);
}
new AlertDialog.Builder(getActivity()).setItems(titles, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which > 0) {
ResolveInfo resolveInfo = listResolveInfo.get(which - 1);
Intent intent = new Intent();
intent.setData(Uri.parse(data));
intent.setClassName(resolveInfo.activityInfo.applicationInfo.packageName, resolveInfo.activityInfo.name);
startActivity(intent);
}
}
}).show();
}
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);
}
Aggregations