Android 使用淘寶瀏覽器打開(kāi)淘寶商品鏈接

調(diào)用

 try {
                Uri uri = Uri.parse(url);
                Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                intent.setClassName("com.taobao.taobao", "com.taobao.browser.BrowserActivity");
                startActivity(intent);
            } catch (Exception e) {
                e.printStackTrace();
                try {
                    /**未安裝淘寶,使用默認(rèn)瀏覽器打開(kāi)*/
                    Uri uri = Uri.parse("https://www.baidu.com");
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    startActivity(intent);
                } catch (Exception e1) {
                    e1.printStackTrace();
                        /**沒(méi)有安裝瀏覽器*/
                }
            }

使用依據(jù)

<activity
            android:theme="@ref/0x7f110331"
            android:name="com.taobao.browser.BrowserActivity"
            android:exported="true"
            android:launchMode="1"
            android:screenOrientation="1"
            android:configChanges="0x4a0"
            android:allowTaskReparenting="true"
            android:windowSoftInputMode="0x12"
            android:overScrollMode="2">

            <intent-filter
                android:priority="-1">

                <category
                    android:name="android.intent.category.DEFAULT" />

                <action
                    android:name="android.intent.action.VIEW" />

                <category
                    android:name="android.intent.category.BROWSABLE" />

                <category
                    android:name="com.taobao.intent.category.HYBRID_UI" />

                <data
                    android:scheme="http" />

                <data
                    android:scheme="https" />

                <data
                    android:scheme="taobao" />
            </intent-filter>

            <intent-filter>

                <category
                    android:name="android.intent.category.DEFAULT" />

                <action
                    android:name="android.intent.action.VIEW" />

                <category
                    android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="http"
                    android:host="*.we.app.jae.m.taobao.com" />
            </intent-filter>

            <intent-filter>

                <category
                    android:name="android.intent.category.DEFAULT" />

                <action
                    android:name="android.intent.action.VIEW" />

                <category
                    android:name="android.intent.category.BROWSABLE" />

                <data
                    android:scheme="http"
                    android:host="login.m.taobao.com"
                    android:path="/taolang/weiboBind.htm" />
            </intent-filter>

            <intent-filter>

                <action
                    android:name="android.intent.action.VIEW" />

                <category
                    android:name="android.intent.category.DEFAULT" />

                <category
                    android:name="android.intent.category.BROWSABLE" />

                <category
                    android:name="com.taobao.intent.category.HYBRID_UI" />

                <data
                    android:scheme="http"
                    android:host="alisec.taobao.com" />
            </intent-filter>
        </activity>

使用AS拿到了淘寶App的清單,發(fā)現(xiàn)有一個(gè)允許外部調(diào)用,標(biāo)明支持以瀏覽器方式打開(kāi)的Activity,應(yīng)該可以用很久吧~.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容