天天看點

Deeplink的打開方式

//這個方法就是我們deepLink的打開,隻要傳入要打開的連結就行
public static void openDeeplink(Context context, String deepLink) {
        Intent intent = null;
        if (null == context || TextUtils.isEmpty(deepLink))
            return;
        try {
            intent = Intent.parseUri(deepLink, Intent.URI_INTENT_SCHEME);
        } catch (URISyntaxException e) {
//            Log.e(TAG, "URISyntaxException: " + e.getLocalizedMessage());
        }
        if (intent != null) {
            intent.setComponent(null);
            try {
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(intent);
            } catch (ActivityNotFoundException e) {
//                Log.e(TAG, "ActivityNotFoundException: " + e.getLocalizedMessage());
            }
        }

    }