美文网首页android
点击网页上的按钮打开本地的app(1)

点击网页上的按钮打开本地的app(1)

作者: emdd2016 | 来源:发表于2017-11-03 18:19 被阅读48次

点击网页上的按钮,判断如果本地已经安装了这个app就打开,如果没有安装就跳转到下载页面去下载

  1. 网页端要做的处理:
loadInstalledApplication = function(){ 
         window.location.href = 'com.demo.app://';
         window.setTimeout(function(){
             if (owner.getPlatformName() == owner.IOS) {
                window.location.href = "http://download.demo.app.com";
             } else if (owner.getPlatformName() == owner.ANDROID) {
                window.location.href = "http://download.demo.app.com";
             }
         },2000)
    }
    

如果只是测试,可以用下边的代码替换上边的代码测试。

  <a href="com.demo.app://">打开app</a>
  1. app端要做的处理:
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:scheme="com.demo.app" />
            </intent-filter>

注意: intent-filter的内容android.intent.action.MAIN和 android.intent.action.VIEW这2个不能同时放到同一个intent-filter中,否则可能会导致app图标找不到。
应该如下:

 <activity
            android:name="...activity.StartActivity"
            android:configChanges="orientation|locale"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            
            <!--网页点击打开本地app-->
            <intent-filter>
                <action android:name="android.intent.action.VIEW" />
                <category android:name="android.intent.category.BROWSABLE" />
                <category android:name="android.intent.category.DEFAULT" />
                <data
                    android:scheme="com.demo.app" />
            </intent-filter>

        </activity>

相关文章

  • 点击网页上的按钮打开本地的app(1)

    点击网页上的按钮,判断如果本地已经安装了这个app就打开,如果没有安装就跳转到下载页面去下载 网页端要做的处理: ...

  • 有什么让你相见恨晚的 iPhone 使用技巧?

    1.在APP Store里安装Screenshot 在用 Safaei打开一个网页 点击分享按钮(底排中间那个按钮...

  • iOS deepLink 唤醒app

    需求 用手机打开我们的网页,点击打开按钮或者收藏按钮,可以直接唤醒app,如果未安装app,则跳转到应用商店提示下...

  • IOS从外部跳到自己的APP客户端

    项目需求 App中有微信分享功能,分享到微信点击打开后是一个网页,网页上有一个"打开客户端"按钮,点击要求跳到自己...

  • qq邮箱IOS版删除多余账号的问题

    打开QQ邮箱APP 然后点击APP右上角的“+”按钮 选择“设置”按钮 点击进入需要删除的邮箱帐号 最后点击下方的...

  • 网页启动Android APK

    点击网页中的URL链接,打开手机中已经存在的Android应用。 网页中URL格式: 打开app 例: 打开app...

  • ios内嵌h5支付【多走一坑】

    app中有个按钮,点击跳转到网页进行支付 _webView = [[WKWebViewalloc] initWit...

  • app下webview问题

    情景:app-点击banner-打开A页面(点击A某个按钮跳转)-B页面(点击B某个按钮跳转)-C页面(点击C某个...

  • iOS-deeplink深入探索

    1.技术产生的背景? 明确的需求就是:手机打开我们的网站,点击打开按钮或者收藏按钮,用户如果已经安装app,跳转到...

  • 判断移动端是否安装某个app

    最近在项目中遇到一个需求: 从app内部分享出去的网页顶部有一个“打开”按钮,用户点击后:1、若用户客户端安装我们...

网友评论

    本文标题:点击网页上的按钮打开本地的app(1)

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