Java Code Examples for android.content.Intent.getScheme()

The following are Jave code examples for showing how to use getScheme() of the android.content.Intent class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: atlas   File: IntentResolver.java   View Source Code Vote up 7 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType, 
        boolean defaultOnly, ArrayList<F[]> listCut) {
    ArrayList<R> resultList = new ArrayList<R>();

    final boolean debug = localLOGV ||
            ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    final String scheme = intent.getScheme();
    int N = listCut.size();
    for (int i = 0; i < N; ++i) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, listCut.get(i), resultList);
    }
    sortResults(resultList);
    return resultList;
}
 
Example 2
Project: letv   File: AlbumLaunchUtils.java   View Source Code Vote up 7 votes
public static void initMParams(Activity activity, Intent intent) {
    if (intent != null && intent.getData() != null) {
        BaseApplication.setAppStartTime(System.currentTimeMillis());
        Uri data = intent.getData();
        LogInfo.log("zhuqiao", "M data" + data);
        String scheme = intent.getScheme();
        if (scheme != null && "letvclient".equalsIgnoreCase(scheme)) {
            DownloadManager.pauseAllDownload();
        }
        if (TextUtils.equals(data.getQueryParameter("version"), "2.0")) {
            mLetvFunctionVersion2(activity, data, intent);
        } else {
            mLetvFunctionVersion1(activity, data, intent);
        }
    }
}
 
Example 3
Project: LittleFlickr   File: MainActivity.java   View Source Code Vote up 7 votes
@Override
protected void onResume() {
    super.onResume();
    //loadOAuth();
    Intent intent = getIntent();
    String scheme = intent.getScheme();
    OAuth savedToken = getOAuthToken();
    if (CALLBACK_SCHEME.equals(scheme) && (savedToken == null || savedToken.getUser() == null)) {
        Uri uri = intent.getData();
        String query = uri.getQuery();

        String[] data = query.split("&"); //$NON-NLS-1$
        if (data != null && data.length == 2) {
            String oauthToken = data[0].substring(data[0].indexOf("=") + 1); //$NON-NLS-1$
            String oauthVerifier = data[1]
                    .substring(data[1].indexOf("=") + 1); //$NON-NLS-1$
            logger.debug("OAuth Token: {}; OAuth Verifier: {}", oauthToken, oauthVerifier); //$NON-NLS-1$

            OAuth oauth = getOAuthToken();
            if (oauth != null && oauth.getToken() != null && oauth.getToken().getOauthTokenSecret() != null) {
                GetOAuthTokenTask task = new GetOAuthTokenTask(this);
                task.execute(oauthToken, oauth.getToken().getOauthTokenSecret(), oauthVerifier);
            }
        }
    }
}
 
Example 4
Project: IFWManager   File: IntentResolver.java   View Source Code Vote up 7 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType,
                                   boolean defaultOnly, ArrayList<F[]> listCut, int userId) {
    ArrayList<R> resultList = new ArrayList<R>();

    final boolean debug = localLOGV ||
            ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    final String scheme = intent.getScheme();
    int N = listCut.size();
    for (int i = 0; i < N; ++i) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, listCut.get(i), resultList, userId);
    }
    sortResults(resultList);
    return resultList;
}
 
Example 5
Project: letv   File: ShareAllChannelActivity.java   View Source Code Vote up 6 votes
private void resolveUri(Intent intent, Uri data) {
    String scheme = intent.getScheme();
    if (scheme != null && "letvclient".equalsIgnoreCase(scheme)) {
        String actionType = "";
        String appName = "";
        String title = "";
        String officialSite = "";
        String text = "";
        String imgUrl = "";
        String playUrl = "";
        String from = "";
        try {
            actionType = data.getQueryParameter("actionType");
            appName = data.getQueryParameter("appName");
            title = data.getQueryParameter("title");
            officialSite = data.getQueryParameter("officialSite");
            text = data.getQueryParameter("text");
            imgUrl = data.getQueryParameter("imgUrl");
            playUrl = data.getQueryParameter("playUrl");
            from = data.getQueryParameter("from");
            packageName = data.getQueryParameter("package");
            invoker = data.getQueryParameter("invoker");
            LogInfo.log("fornia", "ShareAllChannelActivity  getIntent()" + actionType + "|" + appName + "|" + title + "|" + officialSite + "|" + text + "|" + imgUrl + "|" + playUrl + "|" + packageName + "|" + invoker + "|" + from);
            share2Channel(actionType, appName, title, officialSite, text, imgUrl, playUrl, from);
        } catch (NullPointerException e) {
            LogInfo.log("fornia", "NullPointerException e:" + e.getMessage() + "|" + e.toString());
            ToastUtils.showToast(getString(2131100833));
        } catch (Exception e2) {
            ToastUtils.showToast("三方传入参数未知错误,停止分享!");
            LogInfo.log("fornia", "Exception e:" + e2.getMessage() + "|" + e2.toString());
        }
    }
}
 
Example 6
Project: letv   File: AlbumLaunchUtils.java   View Source Code Vote up 6 votes
public static void initLite(Context context, Intent intent) {
    if (intent != null) {
        String scheme = intent.getScheme();
        Uri data = intent.getData();
        if (scheme != null && LITESCHEME.equalsIgnoreCase(scheme) && data != null) {
            String albumId = data.getQueryParameter("aid");
            String videoId = data.getQueryParameter("vid");
            String packageName = data.getQueryParameter("packageName");
            String jsonData = intent.getStringExtra("jsonData");
            String lMode = data.getQueryParameter("launchMode");
            int aid = 0;
            int vid = 0;
            int launchMode = 0;
            if (!TextUtils.isEmpty(albumId)) {
                aid = Integer.parseInt(albumId);
            }
            if (!TextUtils.isEmpty(videoId)) {
                vid = Integer.parseInt(videoId);
            }
            if (!TextUtils.isEmpty(lMode)) {
                launchMode = Integer.parseInt(lMode);
            }
            intent.putExtra("packageName", packageName);
            if (launchMode == 2) {
                intent.putExtra("launchMode", launchMode);
                intent.putExtra("aid", aid);
                intent.putExtra("vid", vid);
            } else if (launchMode == 30) {
                intent.putExtra("launchMode", launchMode);
                intent.putExtra("jsonData", jsonData);
            } else if (context instanceof Activity) {
                Activity activity = (Activity) context;
                if (activity != null) {
                    activity.finish();
                }
            }
        }
    }
}
 
Example 7
Project: letv   File: LitePlayerStartActivity.java   View Source Code Vote up 6 votes
private void initLite(final Intent intent, boolean isCreate) {
    String scheme = intent.getScheme();
    if (!TextUtils.isEmpty(scheme) && AlbumLaunchUtils.LITESCHEME.equalsIgnoreCase(scheme)) {
        this.isLitePlayer = true;
        AlbumLaunchUtils.initLite(this, intent);
        ApkManager.getInstance().setLiteAppCallState(true);
        if (ApkManager.getInstance().getPluginInstallState("com.letv.android.lite") != 1) {
            UIsUtils.setScreenLandscape(this);
            if (isCreate) {
                setContentView(2130903057);
            }
            LetvApplication.getInstance().mCallLiteIntent = intent;
            JarUtil.updatePlugin(this, 1, true);
        } else if (LetvApplication.getInstance().mIsPluginInitedSuccess) {
            JarLaunchUtils.launchLitePlayerDefault(this, intent);
        } else {
            PluginInitedCallback.mPluginInitedListener = new OnPluginInitedListener(this) {
                final /* synthetic */ LitePlayerStartActivity this$0;

                public void onInited() {
                    JarLaunchUtils.launchLitePlayerDefault(this.this$0.mContext, intent);
                }
            };
        }
    } else if (isCreate) {
        setContentView(2130903068);
    }
}
 
Example 8
Project: letv   File: MainActivity.java   View Source Code Vote up 6 votes
private void animEndProcess() {
    this.mMainShow = true;
    getWindow().clearFlags(1024);
    if (VERSION.SDK_INT >= 19) {
        getWindow().addFlags(67108864);
    }
    LogInfo.log("bootPic", "animate end");
    this.contentView.setVisibility(0);
    getWindow().setBackgroundDrawableResource(2131493324);
    this.animationIsFinish = true;
    this.imageLayout.setVisibility(8);
    Intent intent = getIntent();
    Uri data = intent.getData();
    if (data != null) {
        String scheme = intent.getScheme();
        if (scheme != null && SearchMainActivity.LESO_FROM.equalsIgnoreCase(scheme)) {
            if (!isFromThirdParty(data.getQueryParameter("from"))) {
                return;
            }
            return;
        }
    }
    if (!this.initTashIsSuccess || this.mIsFromPush || this.mLaunchByPush || this.mIsForceLaunch) {
        getHomeFragment().setHomeRecordVisible(true);
    } else {
        initPopDialog();
    }
    this.isAnimationIsFinish = true;
}
 
Example 9
Project: letv   File: VipOrderDetailActivity.java   View Source Code Vote up 6 votes
private void initSchemeParams() {
    if (getIntent() != null) {
        Intent intent = getIntent();
        String scheme = intent.getScheme();
        if (!TextUtils.isEmpty(scheme) && "letvclient".equalsIgnoreCase(scheme)) {
            Uri data = intent.getData();
            if (data != null && data.getHost().equalsIgnoreCase(SCHEME_HOST_VIP_ORDER_DETAIL)) {
                PaySucceedActivity.launch(this, PreferencesManager.getInstance().getAlipayAutoProductName(), PreferencesManager.getInstance().getAlipayAutoProductExpire(), PreferencesManager.getInstance().getAlipayAutoProductPrice(), PreferencesManager.getInstance().getAlipayAutoProductPayType(), mCorderId, true);
            }
        }
    }
}
 
Example 10
Project: PretendSharing_Xposed   File: Detector.java   View Source Code Vote up 6 votes
public static String whichShare(Intent realIntent){
        final String a; //temp
        final ComponentName b; //temp
        final String c; //temp
        if ((a = realIntent.getScheme()) != null) { //使用||的话会莫名其妙的空指针,改成遍历数组
            for(String each: TargetIntentSchemes) { //遍历数组
                if (each.equals(a)) {
                    return each;
                }
            }
        }

        else if((b = realIntent.getComponent()) != null){ //新微信
            final String packageName = b.getPackageName();
            final String className = b.getClassName(); //debug用的土方法
            if ("com.tencent.mm".equals(packageName) && "com.tencent.mm.plugin.base.stub.WXEntryActivity".equals(className)
                    && realIntent.getIntExtra("_wxapi_command_type",0) == 2 //命令1是调用微信登录,只有命令2是分享到微博
                    )
                return "weixin";
        }

        /*else if((c = realIntent.getAction()) != null){
            if("com.sina.weibo.sdk.action.ACTION_WEIBO_ACTIVITY".equals(c))
                return "weibo";
        }*/

    return null; //不是分享
}
 
Example 11
Project: VirtualHook   File: IntentResolver.java   View Source Code Vote up 6 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType, boolean defaultOnly,
		ArrayList<F[]> listCut, int userId) {
	ArrayList<R> resultList = new ArrayList<R>();
	FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
	final String scheme = intent.getScheme();
	int N = listCut.size();
	for (int i = 0; i < N; ++i) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, listCut.get(i), resultList, userId);
	}
	sortResults(resultList);
	return resultList;
}
 
Example 12
Project: TPlayer   File: IntentResolver.java   View Source Code Vote up 6 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType, boolean defaultOnly,
		ArrayList<F[]> listCut, int userId) {
	ArrayList<R> resultList = new ArrayList<R>();
	FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
	final String scheme = intent.getScheme();
	int N = listCut.size();
	for (int i = 0; i < N; ++i) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, listCut.get(i), resultList, userId);
	}
	sortResults(resultList);
	return resultList;
}
 
Example 13
Project: container   File: IntentResolver.java   View Source Code Vote up 6 votes
public List<R> queryIntentFromList(Intent intent, String resolvedType, boolean defaultOnly,
		ArrayList<F[]> listCut) {
	ArrayList<R> resultList = new ArrayList<R>();

	final boolean debug = localLOGV || ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);

	FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
	final String scheme = intent.getScheme();
	int N = listCut.size();
	for (int i = 0; i < N; ++i) {
		buildResolveList(intent, categories, debug, defaultOnly, resolvedType, scheme, listCut.get(i), resultList);
	}
	sortResults(resultList);
	return resultList;
}
 
Example 14
Project: atlas   File: IntentResolver.java   View Source Code Vote up 5 votes
public List<R> queryIntent(Intent intent, String resolvedType, boolean defaultOnly) {
    String scheme = intent.getScheme();

    ArrayList<R> finalList = new ArrayList<R>();

    final boolean debug = localLOGV ||
            ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
    F[] firstTypeCut = null;
    F[] secondTypeCut = null;
    F[] thirdTypeCut = null;
    F[] schemeCut = null;

    // If the intent includes a MIME type, then we want to collect all of
    // the filters that match that MIME type.
    if (resolvedType != null) {
        int slashpos = resolvedType.indexOf('/');
        if (slashpos > 0) {
            final String baseType = resolvedType.substring(0, slashpos);
            if (!baseType.equals("*")) {
                if (resolvedType.length() != slashpos+2
                        || resolvedType.charAt(slashpos+1) != '*') {
                    // Not a wild card, so we can just look for all filters that
                    // completely match or wildcards whose base type matches.
                    firstTypeCut = mTypeToFilter.get(resolvedType);
                    secondTypeCut = mWildTypeToFilter.get(baseType);
                } else {
                    // We can match anything with our base type.
                    firstTypeCut = mBaseTypeToFilter.get(baseType);
                    secondTypeCut = mWildTypeToFilter.get(baseType);
                }
                // Any */* types always apply, but we only need to do this
                // if the intent type was not already */*.
                thirdTypeCut = mWildTypeToFilter.get("*");
            } else if (intent.getAction() != null) {
                // The intent specified any type ({@literal *}/*).  This
                // can be a whole heck of a lot of things, so as a first
                // cut let's use the action instead.
                firstTypeCut = mTypedActionToFilter.get(intent.getAction());
            }
        }
    }

    // If the intent includes a data URI, then we want to collect all of
    // the filters that match its scheme (we will further refine matches
    // on the authority and path by directly matching each resulting filter).
    if (scheme != null) {
        schemeCut = mSchemeToFilter.get(scheme);
    }

    // If the intent does not specify any data -- either a MIME type or
    // a URI -- then we will only be looking for matches against empty
    // data.
    if (resolvedType == null && scheme == null && intent.getAction() != null) {
        firstTypeCut = mActionToFilter.get(intent.getAction());
    }

    FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
    if (firstTypeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, firstTypeCut, finalList);
    }
    if (secondTypeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, secondTypeCut, finalList);
    }
    if (thirdTypeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, thirdTypeCut, finalList);
    }
    if (schemeCut != null) {
        buildResolveList(intent, categories, debug, defaultOnly,
                resolvedType, scheme, schemeCut, finalList);
    }
    sortResults(finalList);

    return finalList;
}
 
Example 15
Project: letv   File: MeasurementEvent.java   View Source Code Vote up 5 votes
private static Bundle getApplinkLogData(Context context, String eventName, Bundle appLinkData, Intent applinkIntent) {
    Bundle logData = new Bundle();
    ComponentName resolvedActivity = applinkIntent.resolveActivity(context.getPackageManager());
    if (resolvedActivity != null) {
        logData.putString("class", resolvedActivity.getShortClassName());
    }
    if (APP_LINK_NAVIGATE_OUT_EVENT_NAME.equals(eventName)) {
        if (resolvedActivity != null) {
            logData.putString("package", resolvedActivity.getPackageName());
        }
        if (applinkIntent.getData() != null) {
            logData.putString("outputURL", applinkIntent.getData().toString());
        }
        if (applinkIntent.getScheme() != null) {
            logData.putString("outputURLScheme", applinkIntent.getScheme());
        }
    } else if (APP_LINK_NAVIGATE_IN_EVENT_NAME.equals(eventName)) {
        if (applinkIntent.getData() != null) {
            logData.putString("inputURL", applinkIntent.getData().toString());
        }
        if (applinkIntent.getScheme() != null) {
            logData.putString("inputURLScheme", applinkIntent.getScheme());
        }
    }
    for (String key : appLinkData.keySet()) {
        Object o = appLinkData.get(key);
        String logValue;
        if (o instanceof Bundle) {
            for (String subKey : ((Bundle) o).keySet()) {
                logValue = objectToJSONString(((Bundle) o).get(subKey));
                if (key.equals("referer_app_link")) {
                    if (subKey.equalsIgnoreCase("url")) {
                        logData.putString("refererURL", logValue);
                    } else if (subKey.equalsIgnoreCase("app_name")) {
                        logData.putString("refererAppName", logValue);
                    } else if (subKey.equalsIgnoreCase("package")) {
                        logData.putString("sourceApplication", logValue);
                    }
                }
                logData.putString(key + "/" + subKey, logValue);
            }
        } else {
            logValue = objectToJSONString(o);
            if (key.equals("target_url")) {
                Uri targetURI = Uri.parse(logValue);
                logData.putString("targetURL", targetURI.toString());
                logData.putString("targetURLHost", targetURI.getHost());
            } else {
                logData.putString(key, logValue);
            }
        }
    }
    return logData;
}
 
Example 16
Project: letv   File: MainActivity.java   View Source Code Vote up 5 votes
protected void onApplyPermissionsSuccess() {
    super.onApplyPermissionsSuccess();
    init();
    initFloatBall();
    initDownloadConfig();
    this.mMainFlow = new MainFlow(this, this);
    this.mMainFlow.start();
    this.mMainFlow.requestFindTask();
    this.mMainFlow.requestLocationMessage();
    initExitRetain();
    MyMessageRequest.requestUnreadMessageCountTask(new MessageListener(this) {
        final /* synthetic */ MainActivity this$0;

        {
            if (HotFix.PREVENT_VERIFY) {
                System.out.println(VerifyLoad.class);
            }
            this.this$0 = this$0;
        }

        public void onMessageCount() {
            this.this$0.setMineRedPointVisible(true);
            this.this$0.mMineFragment.refreshNewMessageVisible(true);
        }
    });
    Intent intent = getIntent();
    Uri uri = intent.getData();
    String action = getIntent().getAction();
    if (uri != null) {
        String scheme = intent.getScheme();
        if (scheme == null || !SearchMainActivity.LESO_FROM.equalsIgnoreCase(scheme)) {
            this.mIsEnterFromThirdParty = false;
            initDispBegin();
        } else {
            this.mThirdPartyFrom = uri.getQueryParameter("from");
            if (isFromThirdParty(this.mThirdPartyFrom)) {
                boolean z;
                if (THIRD_PARTY_LETV.equalsIgnoreCase(this.mThirdPartyFrom)) {
                    z = false;
                } else {
                    z = true;
                }
                this.mIsEnterFromThirdParty = z;
                animEndProcess();
                statisticsLaunch(0, false);
            } else {
                this.mIsEnterFromThirdParty = false;
                initDispBegin();
            }
        }
    } else if ("DownloadCompeleReceiver".equals(action)) {
        LogInfo.log("Emerson", "-----------------------DownloadCompeleReceiver");
        animEndProcess();
        LeMessageManager.getInstance().dispatchMessage(new LeMessage(1, new MyDownloadActivityConfig(this).create(0)));
        getIntent().setData(null);
    } else if (intent.getBooleanExtra("isLesoIntoHomePage", false)) {
        this.mIsEnterFromThirdParty = false;
        animEndProcess();
    } else if (intent.getBooleanExtra(MainActivityConfig.IS_FACEBOOK_INTO_HOMEPAGE, false)) {
        this.mIsEnterFromThirdParty = false;
        animEndProcess();
    } else {
        initDispBegin();
    }
    UIs.createShortCut(this.mContext);
    gotoChildPage(getIntent());
    registerLogInOutReceiver();
    registerHomeKeyEventReceiver();
    parseIntentData(getIntent());
    LeMessageManager.getInstance().dispatchMessage(new LeMessage(119));
    PreferencesManager.getInstance().saveLatestLaunchTime();
    PreferencesManager.getInstance().setShowCommentRedDot(true);
    registerTokenLoseReceiver();
    LeMessageManager.getInstance().dispatchMessage(this, new LeMessage(LeMessageIds.MSG_WEBVIEW_UPDATE));
    if (this.mVIPFragment != null) {
        Bundle mBundle = new Bundle();
        mBundle.putSerializable("channel", UIControllerUtils.getVipChannel(this.mContext));
        this.mVIPFragment.setArguments(mBundle);
    }
}
 
Example 17
Project: VirtualHook   File: IntentResolver.java   View Source Code Vote up 5 votes
public List<R> queryIntent(Intent intent, String resolvedType, boolean defaultOnly, int userId) {
	String scheme = intent.getScheme();

	ArrayList<R> finalList = new ArrayList<R>();
	F[] firstTypeCut = null;
	F[] secondTypeCut = null;
	F[] thirdTypeCut = null;
	F[] schemeCut = null;

	// If the intent includes a MIME type, then we want to collect all of
	// the filters that match that MIME type.
	if (resolvedType != null) {
		int slashpos = resolvedType.indexOf('/');
		if (slashpos > 0) {
			final String baseType = resolvedType.substring(0, slashpos);
			if (!baseType.equals("*")) {
				if (resolvedType.length() != slashpos + 2 || resolvedType.charAt(slashpos + 1) != '*') {
					// Not a wild card, so we can just look for all filters
					// that
					// completely match or wildcards whose base type
					// matches.
					firstTypeCut = mTypeToFilter.get(resolvedType);
					secondTypeCut = mWildTypeToFilter.get(baseType);
				} else {
					// We can match anything with our base type.
					firstTypeCut = mBaseTypeToFilter.get(baseType);
					secondTypeCut = mWildTypeToFilter.get(baseType);
				}
				// Any */* types always apply, but we only need to do this
				// if the intent type was not already */*.
				thirdTypeCut = mWildTypeToFilter.get("*");
			} else if (intent.getAction() != null) {
				// The intent specified any type ({@literal *}/*). This
				// can be a whole heck of a lot of things, so as a first
				// cut let's use the action instead.
				firstTypeCut = mTypedActionToFilter.get(intent.getAction());
			}
		}
	}

	// If the intent includes a data URI, then we want to collect all of
	// the filters that match its scheme (we will further refine matches
	// on the authority and path by directly matching each resulting
	// filter).
	if (scheme != null) {
		schemeCut = mSchemeToFilter.get(scheme);
	}

	// If the intent does not specify any data -- either a MIME type or
	// a URI -- then we will only be looking for matches against empty
	// data.
	if (resolvedType == null && scheme == null && intent.getAction() != null) {
		firstTypeCut = mActionToFilter.get(intent.getAction());
	}

	FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
	if (firstTypeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, firstTypeCut, finalList, userId);
	}
	if (secondTypeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, secondTypeCut, finalList, userId);
	}
	if (thirdTypeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, thirdTypeCut, finalList, userId);
	}
	if (schemeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, schemeCut, finalList, userId);
	}
	sortResults(finalList);
	return finalList;
}
 
Example 18
Project: springreplugin   File: IntentMatcherHelper.java   View Source Code Vote up 5 votes
/**
 * 根据 Intent 匹配组件
 *
 * @param context    Context
 * @param intent     调用方传来的 Intent
 * @param filtersMap 插件中声明的所有组件和 IntentFilter
 * @return ComponentInfo
 */
public static String doMatchIntent(Context context, Intent intent, Map<String, List<IntentFilter>> filtersMap) {
    if (filtersMap == null) {
        return null;
    }

    final String action = intent.getAction();
    final String type = intent.resolveTypeIfNeeded(context.getContentResolver());
    final Uri data = intent.getData();
    final String scheme = intent.getScheme();
    final Set<String> categories = intent.getCategories();

    for (Map.Entry<String, List<IntentFilter>> entry : filtersMap.entrySet()) {
        String pluginName = entry.getKey();
        List<IntentFilter> filters = entry.getValue();
        if (filters == null) {
            continue;
        }

        for (IntentFilter filter : filters) {
            int match = filter.match(action, type, scheme, data, categories, "ComponentList");
            if (match >= 0) {
                if (LOG) {
                    LogDebug.d(TAG, "IntentFilter 匹配成功: " + entry.getKey());
                }
                return pluginName;
            } else {
                if (LOG) {
                    String reason;
                    switch (match) {
                        case IntentFilter.NO_MATCH_ACTION:
                            reason = "action";
                            break;
                        case IntentFilter.NO_MATCH_CATEGORY:
                            reason = "category";
                            break;
                        case IntentFilter.NO_MATCH_DATA:
                            reason = "data";
                            break;
                        case IntentFilter.NO_MATCH_TYPE:
                            reason = "type";
                            break;
                        default:
                            reason = "unknown reason";
                            break;
                    }
                    LogDebug.d(TAG, "  Filter did not match: " + reason);
                }
            }
        }
    }
    return "";
}
 
Example 19
Project: TPlayer   File: IntentResolver.java   View Source Code Vote up 5 votes
public List<R> queryIntent(Intent intent, String resolvedType, boolean defaultOnly, int userId) {
	String scheme = intent.getScheme();

	ArrayList<R> finalList = new ArrayList<R>();
	F[] firstTypeCut = null;
	F[] secondTypeCut = null;
	F[] thirdTypeCut = null;
	F[] schemeCut = null;

	// If the intent includes a MIME type, then we want to collect all of
	// the filters that match that MIME type.
	if (resolvedType != null) {
		int slashpos = resolvedType.indexOf('/');
		if (slashpos > 0) {
			final String baseType = resolvedType.substring(0, slashpos);
			if (!baseType.equals("*")) {
				if (resolvedType.length() != slashpos + 2 || resolvedType.charAt(slashpos + 1) != '*') {
					// Not a wild card, so we can just look for all filters
					// that
					// completely match or wildcards whose base type
					// matches.
					firstTypeCut = mTypeToFilter.get(resolvedType);
					secondTypeCut = mWildTypeToFilter.get(baseType);
				} else {
					// We can match anything with our base type.
					firstTypeCut = mBaseTypeToFilter.get(baseType);
					secondTypeCut = mWildTypeToFilter.get(baseType);
				}
				// Any */* types always apply, but we only need to do this
				// if the intent type was not already */*.
				thirdTypeCut = mWildTypeToFilter.get("*");
			} else if (intent.getAction() != null) {
				// The intent specified any type ({@literal *}/*). This
				// can be a whole heck of a lot of things, so as a first
				// cut let's use the action instead.
				firstTypeCut = mTypedActionToFilter.get(intent.getAction());
			}
		}
	}

	// If the intent includes a data URI, then we want to collect all of
	// the filters that match its scheme (we will further refine matches
	// on the authority and path by directly matching each resulting
	// filter).
	if (scheme != null) {
		schemeCut = mSchemeToFilter.get(scheme);
	}

	// If the intent does not specify any data -- either a MIME type or
	// a URI -- then we will only be looking for matches against empty
	// data.
	if (resolvedType == null && scheme == null && intent.getAction() != null) {
		firstTypeCut = mActionToFilter.get(intent.getAction());
	}

	FastImmutableArraySet<String> categories = getFastIntentCategories(intent);
	if (firstTypeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, firstTypeCut, finalList, userId);
	}
	if (secondTypeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, secondTypeCut, finalList, userId);
	}
	if (thirdTypeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, thirdTypeCut, finalList, userId);
	}
	if (schemeCut != null) {
		buildResolveList(intent, categories, defaultOnly, resolvedType, scheme, schemeCut, finalList, userId);
	}
	sortResults(finalList);
	return finalList;
}