jquery 怎样实现h5分享的页面,在浏览器打开,怎样自动跳转到app中,如果手机没有app则调到appstore

jquery 怎样实现h5分享的页面,在浏览器打开,怎样自动跳转到app中,如果手机没有app则调到appstore

阅读 3.8k
1 个回答

1.AndroiManifest.xml中配置
请在App启动的第一个Activity的那个节点中加入

<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:host="arseeds.com"       
                                       android:scheme="zhaojian"/>
</intent-filter>

例如我是以GuideActivity为第一个启动的Activity,配置如下:

<activity android:name=".base.activity.GuideActivity">   
 <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:host="arseeds.com"         
   android:scheme="zhaojian"/> 
   </intent-filter>
</activity>

data中的host和scheme可以自定义

2.在浏览器中唤醒APP
需要在第一个启动的Activity中的onCreate中加入:

 Intent intent = getIntent();
          Uri uri = intent.getData();
        if (uri != null) {     
        String pid = uri.getQueryParameter("pid");  
        }

pid为自定义链接的参数,如果仅仅只是唤醒APP,就可以忽略此步骤

3.在WebView中的唤醒
需要在WebView中配置:


    <html>
       <head>
       <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
                      <title>Insert title here</title>
       </head> 
        <body> 
                  <a href="zhaojian://arseeds.com/?pid=1">打开app</a><br/>
        </body>
     </html>
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题