當前位置: 首頁>>代碼示例>>Java>>正文


Java Intent.getPackage方法代碼示例

本文整理匯總了Java中android.content.Intent.getPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java Intent.getPackage方法的具體用法?Java Intent.getPackage怎麽用?Java Intent.getPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Intent的用法示例。


在下文中一共展示了Intent.getPackage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: queryIntentContentProviders

import android.content.Intent; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public List<ResolveInfo> queryIntentContentProviders(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ProviderInfo pi = getProviderInfo(comp, flags, userId);
        if (pi != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.providerInfo = pi;
            list.add(ri);
        }
        return list;
    }
    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mProviders.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mProviders.queryIntentForPackage(intent, resolvedType, flags, pkg.providers, userId);
        }
        return Collections.emptyList();
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:38,代碼來源:VPackageManagerService.java

示例2: verifyIntent

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Verifies if the intent should be restored.
 */
private void verifyIntent(String intentStr) throws Exception {
    Intent intent = Intent.parseUri(intentStr, 0);
    if (intent.getComponent() != null) {
        verifyPackage(intent.getComponent().getPackageName());
    } else if (intent.getPackage() != null) {
        // Only verify package if the component was null.
        verifyPackage(intent.getPackage());
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:13,代碼來源:GridSizeMigrationTask.java

示例3: shortcutExists

import android.content.Intent; //導入方法依賴的package包/類
/**
 * Returns true if the shortcuts already exists on the workspace. This must be called after
 * the workspace has been loaded. We identify a shortcut by its intent.
 */
private boolean shortcutExists(BgDataModel dataModel, Intent intent, UserHandle user) {
    final String intentWithPkg, intentWithoutPkg;
    if (intent == null) {
        // Skip items with null intents
        return true;
    }
    if (intent.getComponent() != null) {
        // If component is not null, an intent with null package will produce
        // the same result and should also be a match.
        String packageName = intent.getComponent().getPackageName();
        if (intent.getPackage() != null) {
            intentWithPkg = intent.toUri(0);
            intentWithoutPkg = new Intent(intent).setPackage(null).toUri(0);
        } else {
            intentWithPkg = new Intent(intent).setPackage(packageName).toUri(0);
            intentWithoutPkg = intent.toUri(0);
        }
    } else {
        intentWithPkg = intent.toUri(0);
        intentWithoutPkg = intent.toUri(0);
    }

    synchronized (dataModel) {
        for (ItemInfo item : dataModel.itemsIdMap) {
            if (item instanceof ShortcutInfo) {
                ShortcutInfo info = (ShortcutInfo) item;
                if (item.getIntent() != null && info.user.equals(user)) {
                    Intent copyIntent = new Intent(item.getIntent());
                    copyIntent.setSourceBounds(intent.getSourceBounds());
                    String s = copyIntent.toUri(0);
                    if (intentWithPkg.equals(s) || intentWithoutPkg.equals(s)) {
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:44,代碼來源:AddWorkspaceItemsTask.java

示例4: queryIntentReceivers

import android.content.Intent; //導入方法依賴的package包/類
@Override
public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, int userId) {
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		ActivityInfo ai = getReceiverInfo(comp, flags, userId);
		if (ai != null) {
			ResolveInfo ri = new ResolveInfo();
			ri.activityInfo = ai;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mReceivers.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers);
		}
		return null;
	}
}
 
開發者ID:codehz,項目名稱:container,代碼行數:36,代碼來源:VPackageManagerService.java

示例5: queryIntentServices

import android.content.Intent; //導入方法依賴的package包/類
@Override
public List<ResolveInfo> queryIntentServices(Intent intent, String resolvedType, int flags, int userId) {
	checkUserId(userId);
	ComponentName comp = intent.getComponent();
	if (comp == null) {
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
			if (intent.getSelector() != null) {
				intent = intent.getSelector();
				comp = intent.getComponent();
			}
		}
	}
	if (comp != null) {
		final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
		final ServiceInfo si = getServiceInfo(comp, flags, userId);
		if (si != null) {
			final ResolveInfo ri = new ResolveInfo();
			ri.serviceInfo = si;
			list.add(ri);
		}
		return list;
	}

	// reader
	synchronized (mPackages) {
		String pkgName = intent.getPackage();
		if (pkgName == null) {
			return mServices.queryIntent(intent, resolvedType, flags);
		}
		final PackageParser.Package pkg = mPackages.get(pkgName);
		if (pkg != null) {
			return mServices.queryIntentForPackage(intent, resolvedType, flags, pkg.services);
		}
		return null;
	}
}
 
開發者ID:codehz,項目名稱:container,代碼行數:37,代碼來源:VPackageManagerService.java

示例6: queryIntentActivities

import android.content.Intent; //導入方法依賴的package包/類
@Override
public List<ResolveInfo> queryIntentActivities(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        final List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        final ActivityInfo ai = getActivityInfo(comp, flags, userId);
        if (ai != null) {
            final ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }

    // reader
    synchronized (mPackages) {
        final String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mActivities.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mActivities.queryIntentForPackage(intent, resolvedType, flags, pkg.activities, userId);
        }
        return Collections.emptyList();
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:38,代碼來源:VPackageManagerService.java

示例7: queryIntentReceivers

import android.content.Intent; //導入方法依賴的package包/類
@Override
public List<ResolveInfo> queryIntentReceivers(Intent intent, String resolvedType, int flags, int userId) {
    checkUserId(userId);
    flags = updateFlagsNought(flags);
    ComponentName comp = intent.getComponent();
    if (comp == null) {
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
            if (intent.getSelector() != null) {
                intent = intent.getSelector();
                comp = intent.getComponent();
            }
        }
    }
    if (comp != null) {
        List<ResolveInfo> list = new ArrayList<ResolveInfo>(1);
        ActivityInfo ai = getReceiverInfo(comp, flags, userId);
        if (ai != null) {
            ResolveInfo ri = new ResolveInfo();
            ri.activityInfo = ai;
            list.add(ri);
        }
        return list;
    }

    // reader
    synchronized (mPackages) {
        String pkgName = intent.getPackage();
        if (pkgName == null) {
            return mReceivers.queryIntent(intent, resolvedType, flags, userId);
        }
        final VPackage pkg = mPackages.get(pkgName);
        if (pkg != null) {
            return mReceivers.queryIntentForPackage(intent, resolvedType, flags, pkg.receivers, userId);
        }
        return Collections.emptyList();
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:38,代碼來源:VPackageManagerService.java

示例8: isSameIntent

import android.content.Intent; //導入方法依賴的package包/類
public static boolean isSameIntent(Intent a, Intent b) {
    if (a != null && b != null) {
        if (!ObjectsCompat.equals(a.getAction(), b.getAction())) {
            return false;
        }
        if (!ObjectsCompat.equals(a.getData(), b.getData())) {
            return false;
        }
        if (!ObjectsCompat.equals(a.getType(), b.getType())) {
            return false;
        }
        Object pkgA = a.getPackage();
        if (pkgA == null && a.getComponent() != null) {
            pkgA = a.getComponent().getPackageName();
        }
        String pkgB = b.getPackage();
        if (pkgB == null && b.getComponent() != null) {
            pkgB = b.getComponent().getPackageName();
        }
        if (!ObjectsCompat.equals(pkgA, pkgB)) {
            return false;
        }
        if (!ObjectsCompat.equals(a.getComponent(), b.getComponent())) {
            return false;
        }
        if (!ObjectsCompat.equals(a.getCategories(), b.getCategories())) {
            return false;
        }
    }
    return true;
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:32,代碼來源:ComponentUtils.java

示例9: handleUnsupportedLink

import android.content.Intent; //導入方法依賴的package包/類
private static boolean handleUnsupportedLink(final Context context, final IWebView webView, final Intent intent) {
    final String fallbackUrl = intent.getStringExtra(EXTRA_BROWSER_FALLBACK_URL);
    if (fallbackUrl != null) {
        webView.loadUrl(fallbackUrl);
        return true;
    }

    if (intent.getPackage() != null) {
        // The url included the target package:
        final String marketUri = MARKET_INTENT_URI_PACKAGE_PREFIX + intent.getPackage();
        final Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(marketUri));
        marketIntent.addCategory(Intent.CATEGORY_BROWSABLE);

        final PackageManager packageManager = context.getPackageManager();
        final ResolveInfo info = packageManager.resolveActivity(marketIntent, 0);
        final CharSequence marketTitle = info.loadLabel(packageManager);
        showConfirmationDialog(context, marketIntent,
                context.getString(R.string.external_app_prompt_no_app_title),
                R.string.external_app_prompt_no_app, marketTitle);

        // Stop loading, we essentially have a result.
        return true;
    }

    // If there's really no way to handle this, we just let the browser handle this URL
    // (which then shows the unsupported protocol page).
    return false;
}
 
開發者ID:mozilla-mobile,項目名稱:firefox-tv,代碼行數:29,代碼來源:IntentUtils.java

示例10: getIntentPackage

import android.content.Intent; //導入方法依賴的package包/類
private static String getIntentPackage(Intent intent) {
    return intent.getComponent() == null
            ? intent.getPackage() : intent.getComponent().getPackageName();
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:5,代碼來源:InstallShortcutReceiver.java

示例11: getTargetPackage

import android.content.Intent; //導入方法依賴的package包/類
static String getTargetPackage(final Intent intent) {
	final ComponentName component = intent.getComponent();
	return component != null ? component.getPackageName() : intent.getPackage();
}
 
開發者ID:Trumeet,項目名稱:MiPushFramework,代碼行數:5,代碼來源:CondomCore.java

示例12: fromIntent

import android.content.Intent; //導入方法依賴的package包/類
public static ShortcutKey fromIntent(Intent intent, UserHandleCompat user) {
    String shortcutId = intent.getStringExtra(
            ShortcutInfoCompat.EXTRA_SHORTCUT_ID);
    return new ShortcutKey(intent.getPackage(), user, shortcutId);
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:6,代碼來源:ShortcutKey.java

示例13: buildResolveList

import android.content.Intent; //導入方法依賴的package包/類
private void buildResolveList(Intent intent, FastImmutableArraySet<String> categories, boolean debug,
		boolean defaultOnly, String resolvedType, String scheme, F[] src, List<R> dest) {
	final String action = intent.getAction();
	final Uri data = intent.getData();
	final String packageName = intent.getPackage();

	final int N = src != null ? src.length : 0;
	boolean hasNonDefaults = false;
	int i;
	F filter;
	for (i = 0; i < N && (filter = src[i]) != null; i++) {
		int match;

		// Is delivery being limited to filters owned by a particular
		// package?
		if (packageName != null && !isPackageForFilter(packageName, filter)) {
			continue;
		}
		// Do we already have this one?
		if (!allowFilterResult(filter, dest)) {
			continue;
		}

		match = filter.match(action, resolvedType, scheme, data, categories, TAG);
		if (match >= 0) {
			if (!defaultOnly || filter.hasCategory(Intent.CATEGORY_DEFAULT)) {
				final R oneResult = newResult(filter, match);
				if (oneResult != null) {
					dest.add(oneResult);
				}
			} else {
				hasNonDefaults = true;
			}
		}
	}

	if (hasNonDefaults) {
		if (dest.size() == 0) {
			VLog.w(TAG, "resolveIntent failed: found match, but none with CATEGORY_DEFAULT");
		} else if (dest.size() > 1) {
			VLog.w(TAG, "resolveIntent: multiple matches, only some with CATEGORY_DEFAULT");
		}
	}
}
 
開發者ID:codehz,項目名稱:container,代碼行數:45,代碼來源:IntentResolver.java

示例14: startService

import android.content.Intent; //導入方法依賴的package包/類
@Override public ComponentName startService(final Intent service) {
	return service.getComponent() != null ? service.getComponent() : new ComponentName(service.getPackage(), "A");
}
 
開發者ID:oasisfeng,項目名稱:condom,代碼行數:4,代碼來源:CondomMiscTest.java

示例15: buildResolveList

import android.content.Intent; //導入方法依賴的package包/類
private void buildResolveList(Intent intent, FastImmutableArraySet<String> categories,
							  boolean defaultOnly, String resolvedType, String scheme, F[] src, List<R> dest, int userId) {
	final String action = intent.getAction();
	final Uri data = intent.getData();
	final String packageName = intent.getPackage();

	final int N = src != null ? src.length : 0;
	boolean hasNonDefaults = false;
	int i;
	F filter;
	for (i = 0; i < N && (filter = src[i]) != null; i++) {
		int match;

		// Is delivery being limited to filters owned by a particular
		// package?
		if (packageName != null && !isPackageForFilter(packageName, filter)) {
			continue;
		}
		// Do we already have this one?
		if (!allowFilterResult(filter, dest)) {
			continue;
		}

		match = filter.filter.match(action, resolvedType, scheme, data, categories, TAG);
		if (match >= 0) {
			if (!defaultOnly || filter.filter.hasCategory(Intent.CATEGORY_DEFAULT)) {
				final R oneResult = newResult(filter, match, userId);
				if (oneResult != null) {
					dest.add(oneResult);
				}
			} else {
				hasNonDefaults = true;
			}
		}
	}

	if (hasNonDefaults) {
		if (dest.size() == 0) {
			VLog.w(TAG, "resolveIntent failed: found match, but none with CATEGORY_DEFAULT");
		} else if (dest.size() > 1) {
			VLog.w(TAG, "resolveIntent: multiple matches, only some with CATEGORY_DEFAULT");
		}
	}
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:45,代碼來源:IntentResolver.java


注:本文中的android.content.Intent.getPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。