Android Question WebView do not allow URLScheme? net::ERR_UNKOWN_URL_SCHEME

IamTrying

Active Member
Licensed User
WebView is unable to trigger URLScheme?

B4X:
Sub FinishDownload
    Log(">>> FinishDownload")
    'Activity.RemoveAllViews
    'Activity.LoadLayout("2")  
    WebView1.LoadHtml("<html><script>function SMS(){window.location.href='sms:0012127773456';}</script><body onload=SMS(); > or click <a href='sms:0012127773456'>SMS</a></body></html>")
    'WebViewExtras1.addWebChromeClient(WebView1, "")
End Sub

ERR_UNKNOWN_URL_SCHEME.png
 

DonManfred

Expert
Licensed User
Longtime User
Seems that there is no app installed on your device which has registered the scheme sms://
I´m wondering why you want to send a sms from a webview if you already have ALL YOU NEED in the Phone lib of b4a...

B4X:
Dim Sms1 As PhoneSms
Sms1.Send(phone number,"hello")
 
Upvote 0

IamTrying

Active Member
Licensed User
I have my own Java apps and other third party SDK's. who needs the URLScheme trigger.

LAbaYv2.png

EDIT: phone library was included but still same.
 
Upvote 0

BillMeyer

Well-Known Member
Licensed User
Longtime User
Thats Scripting - Won't work in pure WebView
 
Upvote 0

IamTrying

Active Member
Licensed User
Let me clear the confusion.

1. i have primary Java app with third party SDK's (to do audio/video/presentation/logmein etc etc)
2. I need secondary app to trigger URLScheme to my primary APP. (not only SMS service to use)

If i am not wrong. In past it worked with Cordova even. Not sure how to do it in B4A.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
2. I need secondary app to trigger URLScheme to my primary APP. (not only SMS service to use)
You are free to define a new scheme (and your app responsible for this scheme)... Like myscheme://blabla
Any link with the scheme myscheme:// will be starting your app. You app need to read the parameters and parse them...
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
B4X:
AddActivityText(Main,
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!-- Accepts URIs that begin with "beka://service” -->
<data android:scheme="beka" android:host="service" />
</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" />
<!-- Accepts URIs that begin with "beka://kunden” -->
<data android:scheme="beka" android:host="kunden" />
</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" />
<!-- Accepts URIs that begin with "beka://ab” -->
<data android:scheme="beka" android:host="ab" />
</intent-filter>
)

this manifestchange will make the app responsible for the following urls

- beka://kunden/
- beka://service/
- beka://ab/

Link to a sample-project (in the german forum)

PD: Bill; check the sample... This will work using a B4A Webview too :D
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
You are free to define a new scheme (and your app responsible for this scheme)... Like myscheme://blabla
Any link with the scheme myscheme:// will be starting your app. You app need to read the parameters and parse them...
See this examples.

Compile and install serviceapp first. It registers the schemes...
Quit the app
Compile and run wvapp. A wv with a html page from assets is shown. Click on any of the links to open the service app
 

Attachments

  • serviceapp.zip
    7.6 KB · Views: 269
  • wvapp.zip
    7.9 KB · Views: 289
Upvote 0

IamTrying

Active Member
Licensed User
Its working.

[Exception]: FYI

- when i use your sample (works). But when i use your "wvapp.zip" to trigger mine/third party SDK apps similar way, then it still fail like before
- To execute my/third party (closed source) SDK.
when i use following RAW method (without using WebView, WebViewExtra) it do work too

B4X:
Sub callPrimaryApp
    Dim Intent1 As Intent
    ' works : "closedsourcesdk://arg0_arg1_arg2/"
    ' works : "closedsourcesdk://arg0_arg1_arg2"
    Intent1.Initialize(Intent1.ACTION_VIEW, "closedsourcesdk://arg0_arg1_arg2")
    StartActivity(Intent1)
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
The problem seems to be in the scheme parts.
Compare it to real URLs to a domain giving some vars.

For example

Register a scheme
"closedsource"
which is responsible for the domain "sdk".

You then can handle all links to "closedsource://sdk/*

For ex:
closedsource://sdk/arg0/arg1/arg

The app reacts on closedsource://sdk
Everything from the Query (in this case /arg0/arg1/arg) you need to parse yourself. BUT you can use as many parameters you want. You just need to be able to parse it in the main app....
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Something like a few iBeacons ? (On their way by the way - send you the detail later)
This is my last try to contact you...

I´ll answer here as you are not responding to my private Messages since weeks :-(

Any news on this? Or did i upset you somehow?
 
Upvote 0
Top