admin管理员组

文章数量:1597400

清单文件内加入intent-filter

<activity
            android:name=".StartupPageActivity"
            android:launchMode="singleTask"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </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" />
                <data android:scheme="android" android:host="包名"             android:pathPrefix="/open"/>
            </intent-filter>
        </activity>

(在启动页内添加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" />
                <data android:scheme="android" android:host="包名" android:pathPrefix="/open"/>
            </intent-filter>

android:scheme="android"    用来辨别启动的app
android:host="包名"           域名,建议使用应用的包名
android:pathPrefix="/open"  参数路径前缀

H5内使用

< a href="android://包名/open?type=1&id=1">进入XXXAPP内查看</ a>

 

在启动页onCreate()方法内获取intent

Intent intent = getIntent();
        String action = intent.getAction();
        String type= null;
        String id = null;
        if (Intent.ACTION_VIEW.equals(action)) {
            Uri uri = intent.getData();
            if (uri != null) {
                type = uri.getQueryParameter("type");
                id = uri.getQueryParameter("id ");
            }
            Toast.makeText(this,"你是从其他地方跳转进来的吗???",Toast.LENGTH_SHORT).show();
        }

根据参数进行相应判断即可

 

本方法亲测有效(微信禁止scheme跳转,在浏览器内跳转有效

本文标签: 跳转网址XXXAPPapp