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


Java Intent.getComponent方法代碼示例

本文整理匯總了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);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:24,代碼來源:ActivityDelegate.java

示例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;
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:21,代碼來源:VirtualCore.java

示例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);
}
 
開發者ID:didi,項目名稱:VirtualAPK,代碼行數:23,代碼來源:RemoteService.java

示例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;
}
 
開發者ID:amikey,項目名稱:DroidPlugin,代碼行數:18,代碼來源:IPluginManagerImpl.java

示例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);
        }
    }

}
 
開發者ID:NamTranDev,項目名稱:CleanArchitechture,代碼行數:40,代碼來源:Logger.java

示例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;
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:16,代碼來源:RePluginInternal.java

示例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);
	    }
	}
}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:13,代碼來源:InstrumentationHook.java

示例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;
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:22,代碼來源:Utilities.java

示例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);
    }
}
 
開發者ID:didi,項目名稱:VirtualAPK,代碼行數:16,代碼來源:ComponentsHandler.java

示例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();
    }
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:38,代碼來源:VPackageManagerService.java

示例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;
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:39,代碼來源:PluginServiceServer.java

示例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());
}
 
開發者ID:codehz,項目名稱:container,代碼行數:6,代碼來源:ComponentUtils.java

示例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);
        }

    }
 
開發者ID:quaap,項目名稱:LaunchTime,代碼行數:48,代碼來源:ShortcutReceiver.java

示例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;
}
 
開發者ID:JessYanCoding,項目名稱:ProgressManager,代碼行數:57,代碼來源:a.java

示例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;
}
 
開發者ID:LiangMaYong,項目名稱:android-apkbox,代碼行數:7,代碼來源:ApkComponentModifier.java


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