Android Question How to start app from web

androidvh

Member
Licensed User
Longtime User
Hallo,

I like to start my app from a web browser:

I create an Intent Filter to the Manifest Editor

<intent-filter>
    • <data android:scheme="http" />
    • <data android:host="easyoffer.track9.de/" />
    • <action android:name="android.intent.action.VIEW" />
    • <category android:name="android.intent.category.BROWSABLE" />
    • <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

but nothing happend starting the browser...
only the web side is open.

so the question what is to do ?

Kind regards
Volker
 

androidvh

Member
Licensed User
Longtime User
AddManifestText(
<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="19"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<supports-screens android:largeScreens="true"
android:normalScreens="true"
android:smallScreens="true"
android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
'End of default text.

AddApplicationText(

<activity

android:launchMode="singleTask" >
<intent-filter>
<data android:scheme="http" />
<data android:host="easyoffer.track9.de/" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>

)
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Hallo,

I like to start my app from a web browser:

but nothing happend starting the browser...
only the web side is open.

so the question what is to do ?

With the changes you made you tell the system to open this url with your app. But you did not use an unknown scheme. You are still using http. And, viewing a webpage in a browser (registered for scheme http) and you click on an http-link the link will open in the already opened browser. This is expected.

Is it a webpage from you? You have control over it (the page can only be browsed by an androic-device?

You could use an not used scheme and create your own...

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 "myapp://service” -->
<data android:scheme="myapp" android:host="service" />
</intent-filter>
)

This accepts URIs that begin with "myapp://service”
for example in your webpage you have an link like

<a href="myapp://service/">Start Service-App</a>

Your app should be started if you click on "Start Service-App" from within a browser

PS: Hättest Du im deutschen Forum gefragt hättest Du eine deutsche Antwort bekommen :D
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
btw: these will work on win32 too. Just the way "a program register a "new" scheme in the Operatin System" is another than in android. In win32 you need to call windows-sdk-methods... But the principle will work on Windows too. I know; i already did :)
 
Upvote 0

androidvh

Member
Licensed User
Longtime User
Problem is solved:

Manifest:

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" />
<data android:scheme="test" android:host="service" />
</intent-filter>
)

___________________________________
Code:

Dim vh As Intent
vh = Activity.GetStartingIntent

Dim va As String = vh.GetData
If va <> Null Then
If va.StartsWith("test://service/") Then
do something here​
end if

_____________________________________

@DonManfred
Danke, und das nächste Mal vielleicht auf Spanisch....​
 
Upvote 0

aidymp

Well-Known Member
Licensed User
Longtime User
btw: these will work on win32 too. Just the way "a program register a "new" scheme in the Operatin System" is another than in android. In win32 you need to call windows-sdk-methods... But the principle will work on Windows too. I know; i already did :)

Hi @DonManfred could you method for this? I have an android app, that runs from a url, im making the same app in windows and really need this feature!

Thanks

Aidy
 
Last edited:
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
could you code for this?
https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

B4X:
'Delphi Code
procedure Tbekaloader.RegisterProtocol(const Name, Describtion, ExecuteStr: string);
var
  reg: TRegistry;
begin
  reg := TRegistry.Create;
  try
    reg.RootKey := HKEY_CLASSES_ROOT;
    reg.OpenKey(Name, True);
    try
      reg.Writestring('', 'URL:' + Name +' (' + Describtion + ')');
      reg.WriteInteger('EditFlags', 2);
      reg.WriteString('Source Filter', '');
      reg.WriteString('URL Protocol', '');
      reg.OpenKey('shell', True);
      reg.OpenKey('open', True);
      reg.OpenKey('command', True);
      reg.Writestring('', ExecuteStr);
    finally
      reg.CloseKey;
    end;
  finally
    reg.Free;
  end;
end;

'sample use
  RegisterProtocol('BeKa','register protocol BeKa',Application.ExeName + ' %1');
 
Upvote 0

aidymp

Well-Known Member
Licensed User
Longtime User
https://msdn.microsoft.com/en-us/library/aa767914(v=vs.85).aspx

B4X:
'Delphi Code
procedure Tbekaloader.RegisterProtocol(const Name, Describtion, ExecuteStr: string);
var
  reg: TRegistry;
begin
  reg := TRegistry.Create;
  try
    reg.RootKey := HKEY_CLASSES_ROOT;
    reg.OpenKey(Name, True);
    try
      reg.Writestring('', 'URL:' + Name +' (' + Describtion + ')');
      reg.WriteInteger('EditFlags', 2);
      reg.WriteString('Source Filter', '');
      reg.WriteString('URL Protocol', '');
      reg.OpenKey('shell', True);
      reg.OpenKey('open', True);
      reg.OpenKey('command', True);
      reg.Writestring('', ExecuteStr);
    finally
      reg.CloseKey;
    end;
  finally
    reg.Free;
  end;
end;

'sample use
  RegisterProtocol('BeKa','register protocol BeKa',Application.ExeName + ' %1');


No lol, I was expecting some B4J! lol I can sort of follow it though, writing some keys to the registry

But thank you,
 
Upvote 0
Top