在网址中跳转APP(进入XXXAPP内查看)

清单文件内加入intent-filter


            
                
                
            
            
                
                
                
                
            
        

(在启动页内添加intent-filter)


                
                
                
                
            

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

H5内使用

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

 

在启动页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跳转,在浏览器内跳转有效

你可能感兴趣的:(android,app)