美文网首页
Android 使用淘宝浏览器打开淘宝商品链接

Android 使用淘宝浏览器打开淘宝商品链接

作者: DJ沸羊羊 | 来源:发表于2020-01-15 17:50 被阅读0次

    调用

     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 {
                        /**未安装淘宝,使用默认浏览器打开*/
                        Uri uri = Uri.parse("https://www.baidu.com");
                        Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                        startActivity(intent);
                    } catch (Exception e1) {
                        e1.printStackTrace();
                            /**没有安装浏览器*/
                    }
                }
    

    使用依据

    <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的清单,发现有一个允许外部调用,标明支持以浏览器方式打开的Activity,应该可以用很久吧~.

    相关文章

      网友评论

          本文标题:Android 使用淘宝浏览器打开淘宝商品链接

          本文链接:https://www.haomeiwen.com/subject/bsatzctx.html