codename one android intercepting urls issue
Asked Answered
W

1

7

I am having a problem intercepting urls with android on codename one. I got it working fine for ios using the build hints ios.urlScheme and ios.plistInject. The build hint I used for android is:

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> 

However android is not registering the text "mibrand://..." as a link and therefore it is just plain text, not clickable on any android devices. What am I doing wrong?

Here is my php code

<?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>

Then I set the link to share to mylink/share.php?ref=store&id=56

It doesn't work on ios either

Withhold answered 3/5, 2016 at 9:52 Comment(0)
F
3

You need to place this inside an html page and add the link yourself then share that page to your users

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

I've just verified that this works using http://codenameone.com/testm.html which is effectively:

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

And I used the build hint as described above which maps to the codenameone_settings.properties as:

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>

If you need this to work from email just redirect to HTML that includes JavaScript code that redirects to that link.

Feodor answered 3/5, 2016 at 10:29 Comment(3)
Okay but how do I add arguments to that? Like for example the url is different depending on what the person shared so how do I href a url with variables without php. Coz I tried it with a php header function but it doesn't intercept the url?Withhold
This isn't working. I even tried <href="<?php echo $link ?>"></a> Is there no code I can use as reference?Withhold
Try to create a static web page with the <a href='mibrand://...'> open my app </a> link and open this page with the device browserFeodor

© 2022 - 2024 — McMap. All rights reserved.