本文整理汇总了Java中android.content.Intent.getComponent方法的典型用法代码示例。如果您正苦于以下问题:Java Intent.getComponent方法的具体用法?Java Intent.getComponent怎么用?Java Intent.getComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.content.Intent
的用法示例。
在下文中一共展示了Intent.getComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidActivity
import android.content.Intent; //导入方法依赖的package包/类
/**
* Checks whether or not the Intent corresponds to an Activity that should be tracked.
* @param isIncognito Whether or not the TabModel is managing incognito tabs.
* @param intent Intent used to launch the Activity.
* @return Whether or not to track the Activity.
*/
public boolean isValidActivity(boolean isIncognito, Intent intent) {
if (intent == null) return false;
String desiredClassName = isIncognito ? mIncognitoClass.getName() : mRegularClass.getName();
String desiredLegacyClassName = isIncognito
? DocumentActivity.LEGACY_INCOGNITO_CLASS_NAME
: DocumentActivity.LEGACY_CLASS_NAME;
String className = null;
if (intent.getComponent() == null) {
ResolveInfo resolveInfo = ExternalNavigationDelegateImpl.resolveActivity(intent);
if (resolveInfo != null) className = resolveInfo.activityInfo.name;
} else {
className = intent.getComponent().getClassName();
}
return TextUtils.equals(className, desiredClassName)
|| TextUtils.equals(className, desiredLegacyClassName);
}
示例2: resolveActivityInfo
import android.content.Intent; //导入方法依赖的package包/类
public synchronized ActivityInfo resolveActivityInfo(Intent intent, int userId) {
ActivityInfo activityInfo = null;
if (intent.getComponent() == null) {
ResolveInfo resolveInfo = VPackageManager.get().resolveIntent(intent, intent.getType(), 0, userId);
if (resolveInfo != null && resolveInfo.activityInfo != null) {
activityInfo = resolveInfo.activityInfo;
intent.setClassName(activityInfo.packageName, activityInfo.name);
}
} else {
activityInfo = resolveActivityInfo(intent.getComponent(), userId);
}
if (activityInfo != null) {
if (activityInfo.targetActivity != null) {
ComponentName componentName = new ComponentName(activityInfo.packageName, activityInfo.targetActivity);
activityInfo = VPackageManager.get().getActivityInfo(componentName, 0, userId);
intent.setComponent(componentName);
}
}
return activityInfo;
}
示例3: onStartCommand
import android.content.Intent; //导入方法依赖的package包/类
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
if (intent == null) {
return super.onStartCommand(intent, flags, startId);
}
Intent target = intent.getParcelableExtra(EXTRA_TARGET);
if (target != null) {
String pluginLocation = intent.getStringExtra(EXTRA_PLUGIN_LOCATION);
ComponentName component = target.getComponent();
LoadedPlugin plugin = PluginManager.getInstance(this).getLoadedPlugin(component);
if (plugin == null && pluginLocation != null) {
try {
PluginManager.getInstance(this).loadPlugin(new File(pluginLocation));
} catch (Exception e) {
e.printStackTrace();
}
}
}
return super.onStartCommand(intent, flags, startId);
}
示例4: selectStubServiceInfoByIntent
import android.content.Intent; //导入方法依赖的package包/类
@Override
public ServiceInfo selectStubServiceInfoByIntent(Intent intent) throws RemoteException {
ServiceInfo ai = null;
if (intent.getComponent() != null) {
ai = getServiceInfo(intent.getComponent(), 0);
} else {
ResolveInfo resolveInfo = resolveIntent(intent, intent.resolveTypeIfNeeded(mContext.getContentResolver()), 0);
if (resolveInfo.serviceInfo != null) {
ai = resolveInfo.serviceInfo;
}
}
if (ai != null) {
return selectStubServiceInfo(ai);
}
return null;
}
示例5: dump
import android.content.Intent; //导入方法依赖的package包/类
public static void dump(Intent intent) {
if (intent == null) {
e("Intent is null");
return;
}
e("Intent: action: %s", intent.getAction());
if (intent.getPackage() != null) {
e(" pkg: %s", intent.getPackage());
}
if (intent.getType() != null) {
e(" type: %s", intent.getType());
}
if (intent.getComponent() != null) {
e(" comp: %s", intent.getComponent().flattenToString());
}
if (intent.getDataString() != null) {
e(" data: %s", intent.getDataString());
}
if (intent.getCategories() != null) {
for (String cat : intent.getCategories()) {
e(" cat: %s", cat);
}
}
Bundle bundle = intent.getExtras();
if (bundle != null) {
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
e(" extra: %s->%s", key, value);
}
}
}
示例6: getPluginName
import android.content.Intent; //导入方法依赖的package包/类
/**
* 获取插件名称
*/
private static String getPluginName(Activity activity, Intent intent) {
String plugin = "";
if (intent.getComponent() != null) {
plugin = intent.getComponent().getPackageName();
}
// 如果 plugin 是包名,则说明启动的是本插件。
if (TextUtils.isEmpty(plugin) || plugin.contains(".")) {
plugin = RePlugin.fetchPluginNameByClassLoader(activity.getClassLoader());
}
// 否则是其它插件
return plugin;
}
示例7: fallBackToClassNotFoundCallback
import android.content.Intent; //导入方法依赖的package包/类
public static void fallBackToClassNotFoundCallback(Context context,
Intent intent, String componentName) {
if(Framework.getClassNotFoundCallback() !=null){
TrackH5FallBack(componentName);
if(intent.getComponent() == null && !TextUtils.isEmpty(componentName)){
intent.setClassName(context,componentName);
}
if(intent.getComponent()!=null) {
Framework.getClassNotFoundCallback().returnIntent(intent);
}
}
}
示例8: isLauncherAppTarget
import android.content.Intent; //导入方法依赖的package包/类
/**
* Returns true if the intent is a valid launch intent for a launcher activity of an app.
* This is used to identify shortcuts which are different from the ones exposed by the
* applications' manifest file.
*
* @param launchIntent The intent that will be launched when the shortcut is clicked.
*/
public static boolean isLauncherAppTarget(Intent launchIntent) {
if (launchIntent != null
&& Intent.ACTION_MAIN.equals(launchIntent.getAction())
&& launchIntent.getComponent() != null
&& launchIntent.getCategories() != null
&& launchIntent.getCategories().size() == 1
&& launchIntent.hasCategory(Intent.CATEGORY_LAUNCHER)
&& TextUtils.isEmpty(launchIntent.getDataString())) {
// An app target can either have no extra or have ItemInfo.EXTRA_PROFILE.
Bundle extras = launchIntent.getExtras();
return extras == null || extras.keySet().isEmpty();
}
return false;
}
示例9: markIntentIfNeeded
import android.content.Intent; //导入方法依赖的package包/类
public void markIntentIfNeeded(Intent intent) {
if (intent.getComponent() == null) {
return;
}
String targetPackageName = intent.getComponent().getPackageName();
String targetClassName = intent.getComponent().getClassName();
// search map and return specific launchmode stub activity
if (!targetPackageName.equals(mContext.getPackageName()) && mPluginManager.getLoadedPlugin(targetPackageName) != null) {
intent.putExtra(Constants.KEY_IS_PLUGIN, true);
intent.putExtra(Constants.KEY_TARGET_PACKAGE, targetPackageName);
intent.putExtra(Constants.KEY_TARGET_ACTIVITY, targetClassName);
dispatchStubActivity(intent);
}
}
示例10: 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();
}
}
示例11: bindServiceLocked
import android.content.Intent; //导入方法依赖的package包/类
int bindServiceLocked(Intent intent, IServiceConnection connection, int flags, Messenger client) {
intent = cloneIntentLocked(intent);
ComponentName cn = intent.getComponent();
ProcessRecord callerPr = retrieveProcessRecordLocked(client);
ServiceRecord sr = retrieveServiceLocked(intent);
if (sr == null) {
return 0;
}
if (!installServiceIfNeededLocked(sr)) {
return 0;
}
// 将ServiceConnection连接加入各种表中
ProcessBindRecord b = sr.retrieveAppBindingLocked(intent, callerPr);
insertConnectionToRecords(sr, b, connection, flags);
// 判断是否已经绑定过
if (b.intent.hasBound) {
// 之前此Intent已绑定过,则直接返回。像系统那样
// 注意:不管哪个进程,只要第一次绑定过了,其后直接返回。像系统那样
callConnectedMethodLocked(connection, cn, b.intent.binder);
} else {
// 没有绑定,则直接调用onBind,且记录绑定状态
if (b.intent.apps.size() > 0) {
IBinder bd = sr.service.onBind(intent);
b.intent.hasBound = true;
b.intent.binder = bd;
if (bd != null) {
// 为空就不会回调,但仍算绑定成功。像系统那样
callConnectedMethodLocked(connection, cn, bd);
}
}
}
if (LOG) {
LogDebug.i(PLUGIN_TAG, "PSM.bindService(): Bind! inb=" + b + "; fl=" + flags + "; sr=" + sr);
}
return 1;
}
示例12: isStubComponent
import android.content.Intent; //导入方法依赖的package包/类
public static boolean isStubComponent(Intent intent) {
return intent != null
&& intent.getComponent() != null
&& VirtualCore.get().getHostPkg().equals(intent.getComponent().getPackageName());
}
示例13: onReceive
import android.content.Intent; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
if (!BuildConfig.DEBUG) Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(context));
String action = intent.getAction();
if ("com.android.launcher.action.INSTALL_SHORTCUT".equals(action)) {
Log.d("ShortcutCatch", "intent received");
Bundle extras = intent.getExtras();
if (extras != null) {
try {
Log.d("ShortcutCatch", "Shortcut name: " + intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME));
Intent intent2 = (Intent) extras.get(Intent.EXTRA_SHORTCUT_INTENT);
Bitmap receivedicon = (Bitmap) extras.get(Intent.EXTRA_SHORTCUT_ICON);
if (intent2 != null) {
Uri data = intent2.getData();
ComponentName cn = intent2.getComponent();
String intentaction = intent2.getAction();
String shortcutLabel = intent.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
// for (String key: intent2.getExtras().keySet()) {
// Log.d("ShortcutCatch", " extra2: " + key + " = " + intent2.getExtras().get(key));
// }
Log.d("ShortcutCatch", "intent2.action=" + intent2.getAction());
Log.d("ShortcutCatch", "uri=" + data);
if (cn != null) {
Log.d("ShortcutCatch", "cn2package=" + cn.getPackageName() + ", cn2classname=" + cn.getClassName());
addLink(context, shortcutLabel, data, cn, receivedicon);
} else if (intentaction!=null){
Log.d("ShortcutCatch", "intentaction=" + intentaction + " uri=" + data);
addLink(context, intentaction, shortcutLabel, data, receivedicon);
}
}
} catch (Exception e) {
Log.e("ShortcutCatch", "Can't make shortcutlink", e);
}
}
} else {
Log.d("ShortcutCatch", "unknown intent received: " + action);
}
}
示例14: attach
import android.content.Intent; //导入方法依赖的package包/类
final void attach(Context context, ActivityThread aThread,
Instrumentation instr, IBinder token, int ident,
Application application, Intent intent, ActivityInfo info,
CharSequence title, Activity parent, String id,
NonConfigurationInstances lastNonConfigurationInstances,
Configuration config, String referrer, IVoiceInteractor voiceInteractor,
Window window) {
attachBaseContext(context);
mFragments.attachHost(null /*parent*/);
mWindow = new PhoneWindow(this, window);
mWindow.setWindowControllerCallback(this);
mWindow.setCallback(this);
mWindow.setOnWindowDismissedCallback(this);
mWindow.getLayoutInflater().setPrivateFactory(this);
if (info.softInputMode != WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) {
mWindow.setSoftInputMode(info.softInputMode);
}
if (info.uiOptions != 0) {
mWindow.setUiOptions(info.uiOptions);
}
mUiThread = Thread.currentThread();
mMainThread = aThread;
mInstrumentation = instr;
mToken = token;
mIdent = ident;
mApplication = application;
mIntent = intent;
mReferrer = referrer;
mComponent = intent.getComponent();
mActivityInfo = info;
mTitle = title;
mParent = parent;
mEmbeddedID = id;
mLastNonConfigurationInstances = lastNonConfigurationInstances;
if (voiceInteractor != null) {
if (lastNonConfigurationInstances != null) {
mVoiceInteractor = lastNonConfigurationInstances.voiceInteractor;
} else {
mVoiceInteractor = new VoiceInteractor(voiceInteractor, this, this,
Looper.myLooper());
}
}
mWindow.setWindowManager(
(WindowManager)context.getSystemService(Context.WINDOW_SERVICE),
mToken, mComponent.flattenToString(),
(info.flags & ActivityInfo.FLAG_HARDWARE_ACCELERATED) != 0);
if (mParent != null) {
mWindow.setContainer(mParent.getWindow());
}
mWindowManager = mWindow.getWindowManager();
mCurrentConfig = config;
}
示例15: getClassName
import android.content.Intent; //导入方法依赖的package包/类
public static String getClassName(Intent intent) {
if (intent != null && intent.getComponent() != null) {
return intent.getComponent().getClassName();
}
return null;
}