【问题标题】:codename one android intercepting urls issue代号一安卓拦截网址问题
【发布时间】:2016-08-28 07:28:49
【问题描述】:

我在使用代号为 1 的 android 拦截 url 时遇到问题。我使用构建提示 ios.urlScheme 和 ios.plistInject 让它在 ios 上运行良好。我用于 android 的构建提示是:

android.xintent_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="mibrand" />  </intent-filter> 

但是 android 没有将文本“mibrand://...”注册为链接,因此它只是纯文本,在任何 android 设备上都不可点击。我做错了什么?

这是我的 php 代码

<?php

$store = $_GET['ref'];
$id = $_GET['id'];
$link1 = "mibrand://";
$link1 .= $store;
$link1 .= "/";
$link1 .= $id;
$link2 = "http://www.mibrandapp.com";
?>

<a href="<?php echo $link2 ?>"></a>
<a href="<?php echo $link1 ?>"></a>

然后我将要分享的链接设置为 mylink/share.php?ref=store&id=56

在ios上也不能用

【问题讨论】:

    标签: android android-intent codenameone


    【解决方案1】:

    您需要将其放置在一个 html 页面中并自己添加链接,然后将该页面分享给您的用户

    <html>
    ...
    <a href='mibrand://...'> open my app </a>
    ...
    </html>
    

    我刚刚验证了使用http://codenameone.com/testm.html 有效:

    <html>
        <head>
            <title>Mibrand Test</title>
        </head>
        <body>
                <a href="mibrand://launch"> open my app </a>
        </body>
    </html>
    

    我使用了如上所述的构建提示,它映射到codenameone_settings.properties

    codename1.arg.android.xintent_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\="mibrand" />  </intent-filter>
    

    如果您需要从电子邮件中使用此功能,只需重定向到包含重定向到该链接的 JavaScript 代码的 HTML。

    【讨论】:

    • 好的,但是我该如何添加参数呢?例如,网址因人共享的内容而异,所以我如何在没有 php 的情况下使用带有变量的网址。因为我尝试了一个 php 标头函数,但它没有拦截 url?
    • 这不起作用。我什至尝试过 "> 没有可以用作参考的代码吗?
    • 尝试使用打开我的应用链接创建一个静态网页并使用设备浏览器打开此页面
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-16
    • 2012-06-08
    • 1970-01-01
    • 2011-10-22
    • 1970-01-01
    • 2020-09-18
    • 1970-01-01
    相关资源
    最近更新 更多