Make it the default browser

1,462 views
Skip to first unread message

Thiemo Melhorn

unread,
Jan 27, 2023, 12:52:33 AM1/27/23
to DroidScript
How to change the default browser by button? Because I want my web browser to have this feature too and that everything is displayed in my browser.

Jumar

unread,
Jan 27, 2023, 3:19:51 AM1/27/23
to DroidScript
Hi Thiemo

Browsing online, I found this as part of Manifest.xml file to enable your app to be recognized as a Browser by the Android system and can be set on `Default Browser` in your phone's settings.

<intent-filter>
     <action android:name="android.intent.action.VIEW" />
     <category android:name="android.intent.category.BROWSABLE" />
     <data android:scheme="http" />
     <data android:scheme="https" />
</intent-filter>

If you can convert it into json to be added on the `build.json` file of your DS app, maybe it can solve your query.

Regards
Jumar

PS. I don't really sure if the manifest statements is correct because I just search it online.

Thiemo Melhorn

unread,
Jan 27, 2023, 4:58:17 AM1/27/23
to DroidScript
2023_01_27_10.55.57.jpg

Right2TheV0id

unread,
Jan 27, 2023, 10:54:00 AM1/27/23
to DroidScript
This is not how build.json works.
You can find informations about this file in the official doc: https://symdstools.github.io/Docs/docs/intro/07FileStructure.htm

Le vendredi 27 janvier 2023 à 10:58:17 UTC+1, Thiemo Melhorn a écrit :
2023_01_27_10.55.57.jpg

Alan Hendry

unread,
Jan 28, 2023, 3:06:37 PM1/28/23
to DroidScript
Hi,
build.json has to be in JSON format,
This is an example, I think the path pattern means that when the app has been built (APK or AAB) and installed then when the user opens PNG or jpg  files then the user can choose to use this app to open it.

{
    "manifest":
    {
        "minSdkVersion": 23,
        "targetSdkVersion": 28,
        "debuggable": false,
        "removePermissions": "WRITE\_EXTERNAL\_STORAGE",
        "homeScreen": false,
        "noPermsAction": "default",
        "pathPattern": ".*\.png,.*\.jpg"
    },
    "autoPermissions": true
}

Regards, ah

Thiemo Melhorn

unread,
Jan 29, 2023, 2:28:23 AM1/29/23
to DroidScript
The same error appears again.

Thiemo Melhorn

unread,
Jan 29, 2023, 2:43:01 AM1/29/23
to DroidScript
However, once I run the APK, it works without any problems.

Thiemo Melhorn

unread,
Jan 29, 2023, 9:18:36 AM1/29/23
to DroidScript
Is the browser now displayed as the default web browser with Alan's code?

Alan Hendry

unread,
Jan 29, 2023, 12:58:38 PM1/29/23
to DroidScript

HI,
On second thought this technique means that when the user tries to open a .htm file 
then the user would be given the choice of opening the file with this app 
(the json would need to be changed to .htm and.html).
There may be an intent that will open the correct settings page 
for the user to change the default app for browsing the web (may not be relevant on some versions of Android)
Regards, ah

Thiemo Melhorn

unread,
Jan 29, 2023, 3:46:24 PM1/29/23
to DroidScript
Thanks to a tutorial - the tutorial is available in the tutorials in DS - I have not found anything about my project but about the dialog box.

//Called when application is started.
function OnStart()
{
 //Create a layout with objects vertically centered.
 lay = app.CreateLayout( "linear", "VCenter,FillXY" )
 //Create image.
 img = app.CreateImage( "/Sys/Img/Hello.png", 0.1 )
 lay.AddChild( img )
 //Create a 'Send File' button
 btnSend = app.CreateButton( "Send File to another App", 0.8 )
 btnSend.SetMargins( 0, 0.05, 0, 0 )
 btnSend.SetOnTouch( btnSend_OnTouch )
 lay.AddChild( btnSend )
 //Create a 'Send Image' button
 btnImg = app.CreateButton( "Send Image to Google Drive", 0.8 )
 btnImg.SetMargins( 0, 0.05, 0, 0 )
 btnImg.SetOnTouch( btnImg_OnTouch )
 lay.AddChild( btnImg )
 //Create a 'Send Text' button
 btnTxt = app.CreateButton( "Send Text to Google Drive", 0.8 )
 btnTxt.SetMargins( 0, 0.05, 0, 0 )
 btnTxt.SetOnTouch( btnTxt_OnTouch )
 lay.AddChild( btnTxt )
 //Add layout to app.
 app.AddLayout( lay )
}
//Send a file to another App (user's choice).
function btnSend_OnTouch()
{
    var file = "/sdcard/sftest.txt";
    app.WriteFile( file, "Hello World" )
 app.SendFile( file, "sftest.txt", "Send File" )
}
//Send an image to Google Drive.
function btnImg_OnTouch()
{
    var file = "/sdcard/MyDroid.jpg";
    img.Save( file )
    var packageName = "com.google.android.apps.docs";
    var className = "com.google.android.apps.docs.shareitem.UploadSharedItemActivity";
    var action = "android.intent.action.SEND";
    var category = "android.intent.category.DEFAULT"
    var uri = null;
    var type = "multipart/*";
    var extras = [
        {name:"android.intent.extra.STREAM", type:"file", value:file},
        {name:"android.intent.extra.SUBJECT", type:"string", value:"MyDroid.jpg"},
    ];
    extras = JSON.stringify( extras )
    app.SendIntent(packageName, className, action, category, uri, type, extras)
}
//Send text to Google Drive.
function btnTxt_OnTouch()
{
    var textData = "The cat sat on the mat";
    var packageName = "com.google.android.apps.docs";
    var className = "com.google.android.apps.docs.shareitem.UploadSharedItemActivity";
    var action = "android.intent.action.SEND";
    var category = "android.intent.category.DEFAULT"
    var uri = null;
    var type = "text/plain";
    var extras = [
        {name:"android.intent.extra.TEXT", type:"string", value:textData},
    ];
    extras = JSON.stringify( extras )
    app.SendIntent(packageName, className, action, category, uri, type, extras)
}

Jumar

unread,
Jan 30, 2023, 8:43:39 AM1/30/23
to DroidScript
Hi what I mean about the json format is something like this

{
    "manifest":
    {
        "minSdkVersion": 23,
        "targetSdkVersion": 28,
        "debuggable": false,
        
        "action": "android.intent.action.VIEW",
        "category": "android.intent.category.BROWSABLE"
    }
}

And I don't think it's the right way to do it. You also need to set the scheme which I think is the pathPattern equivalent.

If you want to set your app as the default browser within your app app.SendIntent would be the right way to do it. But I'm afraid there's no enough information in this forum about those values that we need to pass in app.SendIntent especially the extras thing.

Maybe something like.

    var action = "android.intent.action.CHOOSER";
    var category = "android.intent.category.BROWSABLE"
    var uri = null;
    var type = "";
    var extras = [
        {name:"android.intent.extra.INTENT", type:"STRING", value:"Select default browser"},
        ... another extras goes here
    ];
    extras = JSON.stringify( extras )
    app.SendIntent(null, null, action, category, uri, type, extras)

Regards
Jumar

Thiemo Melhorn

unread,
Jan 30, 2023, 9:35:21 AM1/30/23
to DroidScript
As soon as I run the code in the development app, nothing happens. Do I need to add the code to a function with a button?

Thiemo Melhorn

unread,
Jan 30, 2023, 9:52:27 AM1/30/23
to DroidScript
I believe that all the code belongs in a function of a button but I am unsure about this.

Dave

unread,
Jan 31, 2023, 1:55:07 PM1/31/23
to DroidScript
You should be able to use the 'deep linking' feature of DS to achieve this - 

{
    "manifest": {
        "urlScheme": "https",
        "urlHost": "*"
    }
}

or maybe this - 

{
    "manifest": {
        "urlScheme": "https",
        "urlHost": ""
    }
}


Alan Hendry

unread,
Jan 31, 2023, 2:01:35 PM1/31/23
to DroidScript
Hi,
Pretty sure that if the build.json works then as soon as the user installs the app then it will become the default browser, so a button cannot turn it on and off.
In the browser tabs app the webview cannot show videos, so the user can open the URL in the default browser, may need changing to try and open Chrome specifically.
As far as I recall, it's possible for intents to open Android Settings screens, but the user has to make the update. See
ACTION_APP_OPEN_BY_DEFAULT_SETTINGS
ACTION_MANAGE_DEFAULT_APPS_SETTINGS
Regards, ah
Message has been deleted

Alan Hendry

unread,
Mar 19, 2023, 11:39:14 AM3/19/23
to DroidScript
HI,
Reportedly neither of these build.jsons do the trick.
Some websites seem to suggest specifyng action (view), categories (default and browsable) and data (http and https).
I presume that this should allow the user to choose this app when opening links, and when choosing an app to be the default browser.
Regards, ah

Right2TheV0id

unread,
Mar 19, 2023, 2:37:38 PM3/19/23
to DroidScript
As we already stated that a webview based browser isn't a full-fledged browser, isn't asking to provide the ability to make an app recognized as a "browser" beyond the scope of DroidScript?
I ask this to point out the fact that, even if it could happen one day, it might get very low on the priorities list.

Alan Hendry

unread,
Mar 19, 2023, 2:59:41 PM3/19/23
to DroidScript
HI,
I think that we really want user's to click on a URL (in any app) 
and open this app
(or at least give the user a list of apps that can open URLs, let them choose once or always).
Regards, ah

Right2TheV0id

unread,
Mar 19, 2023, 3:13:37 PM3/19/23
to DroidScript
Isn't it the default behavior when no default browser has been set?
A solution would be to ask the user to remove the default browser setting.

Alan Hendry

unread,
Mar 20, 2023, 6:16:13 AM3/20/23
to DroidScript
HI,
I can't set it to have no default browser (radio buttons in android 8).
As far as I can tell android shows a list of apps that can accept intents to view URLs.
Regards, ah

Right2TheV0id

unread,
Mar 20, 2023, 6:53:26 AM3/20/23
to DroidScript
You're right, this is more tricky than I thought.
The only way I managed to get the behavior I described was by uninstalling all the apps recognized as potential "default browser" by Android (I don't recommend to do it).
Then I when I click a link, a chooser prompts to choose an app to continue, with all my DS apps able to open links listed.
For this to work build.json needs those entries:
"urlHost": "*",
"urlScheme": "http,https"

People also proposes to use special apps as default browser that will catch every links and always open a chooser prompt to le the user decide which app to use:

Alan Hendry

unread,
Mar 21, 2023, 11:50:35 AM3/21/23
to DroidScript
Hmm, 
Can't seem to get the app to appear when opening a url or htm or changing default browser.
Does anyone have an example of "deep linking" (any type) that has worked in the past?
That should allow us to check that it works in current version of DS
Regards, ah

Right2TheV0id

unread,
Mar 21, 2023, 1:54:12 PM3/21/23
to DroidScript
I tested it successfully on Android 7.1 with DS 2.57 and Android 11 DS 2.60b1_p3.
Here's the full build.json file:

{
    "manifest":
    {
        "minSdkVersion": 23,
        "targetSdkVersion": 28,
        "debuggable": false,
        "urlHost": "*",
        "urlScheme": "http,https"
    }
}

Alan Hendry

unread,
Mar 26, 2023, 6:27:15 AM3/26/23
to DroidScript
HI,
If I try to open a link in Chrome then it just opens it in Chrome,
  1. and Gmail opens links in Gmail (probably has its own webview).
I wrote a small app to issue an intent, and that does open the testbrowser app.
Files app always seems to open html files in Chrome (default browser).
Several web pages seem to document having multiple filters,
don't know how to do that in build.json (or if we can).
Regards, ah

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="http" />
                <data android:scheme="https" />
                <data android:scheme="about" />
                <data android:scheme="javascript" />
            </intent-filter>
            <!--  For these schemes where any of these particular MIME types
                  have been supplied, we are a good candidate. -->

            <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="http" />
                <data android:scheme="https" />
                <data android:scheme="inline" />
                <data android:mimeType="text/html"/>
                <data android:mimeType="text/plain"/>
                <data android:mimeType="application/xhtml+xml"/>
                <data android:mimeType="application/vnd.wap.xhtml+xml"/>
            </intent-filter>
            <!-- We are also the main entry point of the browser. -->
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.DEFAULT" />
                <category android:name="android.intent.category.LAUNCHER" />

                <category android:name="android.intent.category.BROWSABLE" />
            </intent-filter>

Alan Hendry

unread,
Mar 28, 2023, 10:32:31 AM3/28/23
to DroidScript
HI,
Here's my little app that sends an intent to view a https, send a html file, 
intent to view html file, and intent to change default browser.
Regards, ah

Right2TheV0id

unread,
Mar 28, 2023, 12:44:33 PM3/28/23
to DroidScript
I think that you forgot to join your app to your message.

Alan Hendry

unread,
Mar 28, 2023, 1:01:54 PM3/28/23
to DroidScript
Here it is
intent_browser.spk

Alan Hendry

unread,
Mar 29, 2023, 10:39:09 AM3/29/23
to DroidScript
HI,
I tried to add pathPattern  to build.json to open htm and html files,
but it doesn't seem to work
Regards, ah

{
    "manifest":
    {
        "minSdkVersion": 23,
        "targetSdkVersion": 28,
        "debuggable": false,
        "urlHost": "*",
        "urlScheme": "http,https",
        "pathPattern":".*\\.htm,.*\\.html"
    }
}

Right2TheV0id

unread,
Mar 29, 2023, 11:46:11 AM3/29/23
to DroidScript
Didn't dig in it, but opening a specific file extension in android seems to be a tricky taske according to this SO answer:
https://stackoverflow.com/a/31028507
Message has been deleted
Message has been deleted
Message has been deleted

Alan Hendry

unread,
Mar 31, 2023, 9:35:40 AM3/31/23
to DroidScript
HI,
It seems to confirm the format of path pattern
Tried with a single extension in the path pattern, was no better.
I've added code to show a button that opens the YouTube app
(if URL contains YouTube and v= and app is installed)
Should probably add code to show/gone the icon on switching tabs
It won't let me attach my APK here (that's why two posts show as deleted.
Gonna try discord
Regards, ah

Right2TheV0id

unread,
Apr 1, 2023, 6:41:21 AM4/1/23
to DroidScript
I reposted here the SPK you shared on Discord as I don't think Thiemo visits it.
I also sometimes get my posts randomly removed for no precise reason.
Apparently Google Groups is getting capricious over the years.

Testbrowser.spk

Alan Hendry

unread,
Apr 1, 2023, 11:47:55 AM4/1/23
to DroidScript
Thanks,
I'd actually sent Thiemo a copy thru Telegram
At least everyone can now see it
Regards, ah

Thiemo Melhorn

unread,
Apr 3, 2023, 12:08:16 PM4/3/23
to DroidScript
Switching the default browser does not work either. Why or what codes do I still need with it?

Thiemo Melhorn

unread,
Apr 9, 2023, 3:07:25 PM4/9/23
to DroidScript
I got this code from someone else for the JSON file. Alan told me that many things DS does himself or not all and I do not know what things are still necessary for the JSON file.
"name": "Meine Browser-App",

"version": "1.0",

"description": "Eine großartige Browser-App",

"icons": {

"16": "icon16.png",

"32": "icon32.png",

"128": "icon128.png"

},

"permissions": [

"activeTab",

"tabs"

],

"background": {

"scripts": [

"background.js"

]

},

"content_security_policy": "script-src 'self' https://apis.google.com; object-src 'self'",

"web_accessible_resources": [

"images/*"

],

"start_url": "index.html",

"theme_color": "#ffffff"

}

Right2TheV0id

unread,
Apr 9, 2023, 7:23:37 PM4/9/23
to DroidScript
What did you try to achieve with this JSON file?
A quick Google search with "web_accessible_resources" yields various results about "Manifest V3", "Chrome extension" and "Firefox extension".
I'm not 100% sure of what it is exactly, but I can tell you that it is not related/applicable to DroidScript.
Here is the documentation page containing information about the build.json file:

Thiemo Melhorn

unread,
Apr 9, 2023, 10:53:45 PM4/9/23
to DroidScript
First still nothing, I tried with it. What could be the reason that DS or Android does not want to set as default browser?

Right2TheV0id

unread,
Apr 10, 2023, 5:01:56 AM4/10/23
to DroidScript
This is something doable if you develop a regular Android application, but currently beyond the scope of DroidScript.
Jumar gave you the reason in this post: 
https://groups.google.com/g/androidscript/c/Z4tR26I879U/m/9PNvTMtPBgAJ

At the moment the best you can achieve is what I described here: 

In my personal opinion you might now have enough information in this thread to either decide what to do.
The only left thing you could try could be altering the generated apk/aab manifest, but this is a difficult task (and again, beyond the scope of DroidScript).
Date posted about it some years ago:

Alan Hendry

unread,
Apr 12, 2023, 5:18:49 AM4/12/23
to DroidScript
HI,
We've tried several build.json settings.
There's a keyword for making the app eligible to be Android Home
(which I presume the builder transforms into the manifest.xml.
I posit a special keyword in the manifest that makes the app eligible to be the default browser (or there's a specific combination of other keywords).
We'd need to find the special keyword (or combination of keywords) and figure out what to put in the build.json and make sure the builder can transform it/them.
Regards, ah

Dave

unread,
Apr 12, 2023, 9:47:09 AM4/12/23
to DroidScript
If my suggestions for the build.json above did not work, then someone needs to experiment with a manifest editing app and see what combination works.  

It would also be useful if someone let me know what the following build.json generates in the manifest (use one of the free manifest viewing apps)

{
    "manifest": {
        "urlScheme": "https",
        "urlHost": "*"
    }
}

I would expect to see something like this in the manifest - 

<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="https" android:host="*"/>
</intent-filter>


Which should do the job you want (in theory).


This would also be worth trying - 

{
    "manifest": {
        "urlScheme": "https,http",
        "urlHost": "*,*",
        "urlPathPrefix": "/,/"
    }
}

Alan Hendry

unread,
Apr 12, 2023, 11:12:29 AM4/12/23
to DroidScript
HI,
The small test app below 
shows our main app as an option when issuing a view intent for https,
but not for send file, intent to view a file, or choose default browser.
Currently have build.json of
{
    "manifest":
    {
        "minSdkVersion": 23,
        "targetSdkVersion": 28,
        "debuggable": false,
        "urlHost": "*",
        "urlScheme": "http,https"
    }
}
Have tried adding path pattern for htm and html but it seemed to have no effect
(I suspect that it's for files only and should be used without URL host and scheme)

Regards, ah


function OnStart() {
lay = app.CreateLayout( "linear", "VCenter,FillXY" );

bt1=app.AddButton( lay,"sendintent https" )
bt1.SetOnTouch( function() {
   app.SendIntent(null, null,"android.intent.action.VIEW",null,"https://droidscript.org");
})

bt2=app.AddButton( lay,"sendfile" )
bt2.SetOnTouch(function() {
   app.SendFile(  app.GetAppPath()+"/test.html")
 })

bt3=app.AddButton( lay, "sendintent file" )
bt3.SetOnTouch( function() {
   url = app.Path2Uri(   app.GetPath()+"/test.html")
   app.SendIntent( null,null,"android.intent.action.VIEW",null,url)
})

btn=app.AddButton( lay,"change default" )
btn.SetOnTouch( function() {
   app.SendIntent( null,null,"android.settings.MANAGE_DEFAULT_APPS_SETTINGS" )
})

app.AddLayout( lay );
}

Thiemo Melhorn

unread,
Apr 12, 2023, 10:15:25 PM4/12/23
to DroidScript
I have tried all this but unfortunately it does not work. I think you would have to do this not only in the JSON file, but also in the actual file.

Thiemo Melhorn

unread,
Apr 12, 2023, 10:17:46 PM4/12/23
to DroidScript
But I'm sticking with it and not giving up. Eventually it will work with your help.

Thiemo Melhorn

unread,
Apr 12, 2023, 10:23:18 PM4/12/23
to DroidScript
I don't know if this is the solution for my app.

Alan Hendry

unread,
Apr 13, 2023, 10:15:21 AM4/13/23
to DroidScript
HI,
This just shows to send an intent, which we've already used to test sending intents.
It just doesn't address how to be eligible to be the default browser, or open html files.
Regards, ah

Thiemo Melhorn

unread,
Apr 13, 2023, 4:38:58 PM4/13/23
to DroidScript
Isn't that an approach?

Alan Hendry

unread,
Apr 13, 2023, 4:47:50 PM4/13/23
to DroidScript
No 
We need it to be that when the user goes into settings to set the default browser,
then testbrowser appears in the list.
This doesn't affect that at all.
Regards, ah

Thiemo Melhorn

unread,
Apr 13, 2023, 5:27:13 PM4/13/23
to DroidScript
Could the support/administrator or developer help?
Message has been deleted

Steve Garman

unread,
Apr 14, 2023, 3:16:35 AM4/14/23
to DroidScript
I have deleted my last post because I thought I was posting in a different thread where my counsel of despair was more appropriate 

There is a lot of interesting discussion in this thread that may prove productive at some point so I won't post similar advice in the thread I intended it for

Alan Hendry

unread,
Apr 14, 2023, 6:47:48 AM4/14/23
to DroidScript
HI,
See Dave's posts above.
Strangely in DS docs for Material UI (Premium) there's a section Website 
touching it gives me the choice of opening in Chrome or different app which includes Testbrowser. Perhaps it's using view intent on the https URL.
There are loads of manifest examples with multiple filter elements, some indicate that browsers also handle the list of favourites.
Suggestions on web pages include categories default, browsable, launcher,
and (probably most promising) category app_browser
also mime types (I get errors if I try that, maybe I haven't got the correct keyword or builder doesn't support it)
For an example see 
Regards, ah

Thiemo Melhorn

unread,
Apr 14, 2023, 7:37:59 AM4/14/23
to DroidScript
Dankeschön, Alan!

Thiemo Melhorn

unread,
Apr 14, 2023, 3:40:30 PM4/14/23
to DroidScript
Would this work here like this in DS?

{
   "manifest": {
      "original-package": {
         "_android:name": "com.android.browser"
      },
      "uses-permission": [
         {
            "_android:name": "android.permission.ACCESS_COARSE_LOCATION"
         },
         {
            "_android:name": "android.permission.ACCESS_DOWNLOAD_MANAGER"
         },
         {
            "_android:name": "android.permission.ACCESS_FINE_LOCATION"
         },
         {
            "_android:name": "android.permission.ACCESS_NETWORK_STATE"
         },
         {
            "_android:name": "android.permission.ACCESS_WIFI_STATE"
         },
         {
            "_android:name": "com.android.launcher.permission.INSTALL_SHORTCUT"
         },
         {
            "_android:name": "android.permission.INTERNET"
         },
         {
            "_android:name": "android.permission.SET_WALLPAPER"
         },
         {
            "_android:name": "android.permission.WAKE_LOCK"
         },
         {
            "_android:name": "android.permission.WRITE_EXTERNAL_STORAGE"
         },
         {
            "_android:name": "android.permission.WRITE_SETTINGS"
         },
         {
            "_android:name": "com.android.browser.permission.READ_HISTORY_BOOKMARKS"
         },
         {
            "_android:name": "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
         },
         {
            "_android:name": "android.permission.SEND_DOWNLOAD_COMPLETED_INTENTS"
         }
      ],
      "application": {
         "provider": {
            "path-permission": {
               "_android:path": "/bookmarks/search_suggest_query",
               "_android:readPermission": "android.permission.GLOBAL_SEARCH"
            },
            "_android:name": "BrowserProvider",
            "_android:authorities": "browser",
            "_android:multiprocess": "true",
            "_android:readPermission": "com.android.browser.permission.READ_HISTORY_BOOKMARKS",
            "_android:writePermission": "com.android.browser.permission.WRITE_HISTORY_BOOKMARKS"
         },
         "activity": [
            {
               "intent-filter": [
                  {
                     "action": [
                        {
                           "_android:name": "android.speech.action.VOICE_SEARCH_RESULTS"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        }
                     ]
                  },
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.VIEW"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        },
                        {
                           "_android:name": "android.intent.category.BROWSABLE"
                        }
                     ],
                     "data": [
                        {
                           "_android:scheme": "http"
                        },
                        {
                           "_android:scheme": "https"
                        },
                        {
                           "_android:scheme": "about"
                        },
                        {
                           "_android:scheme": "javascript"
                        }
                     ]
                  },
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.VIEW"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.BROWSABLE"
                        },
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        }
                     ],
                     "data": [
                        {
                           "_android:scheme": "http"
                        },
                        {
                           "_android:scheme": "https"
                        },
                        {
                           "_android:scheme": "inline"
                        },
                        {
                           "_android:mimeType": "text/html"
                        },
                        {
                           "_android:mimeType": "text/plain"
                        },
                        {
                           "_android:mimeType": "application/xhtml+xml"
                        },
                        {
                           "_android:mimeType": "application/vnd.wap.xhtml+xml"
                        }
                     ]
                  },
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.MAIN"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        },
                        {
                           "_android:name": "android.intent.category.LAUNCHER"
                        },
                        {
                           "_android:name": "android.intent.category.BROWSABLE"
                        }
                     ]
                  },
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.WEB_SEARCH"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        },
                        {
                           "_android:name": "android.intent.category.BROWSABLE"
                        }
                     ],
                     "data": [
                        {
                           "_android:scheme": ""
                        },
                        {
                           "_android:scheme": "http"
                        },
                        {
                           "_android:scheme": "https"
                        }
                     ]
                  },
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.MEDIA_SEARCH"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        }
                     ]
                  },
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.SEARCH"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        }
                     ]
                  }
               ],
               "meta-data": {
                  "_android:name": "android.app.searchable",
                  "_android:resource": "@xml/searchable"
               },
               "_android:name": "BrowserActivity",
               "_android:label": "@string/application_name",
               "_android:launchMode": "singleTask",
               "_android:alwaysRetainTaskState": "true",
               "_android:configChanges": "orientation|keyboardHidden",
               "_android:theme": "@style/BrowserTheme",
               "_android:windowSoftInputMode": "adjustResize"
            },
            {
               "meta-data": {
                  "_android:name": "android.app.default_searchable",
                  "_android:value": ".BrowserActivity"
               },
               "intent-filter": [
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.MAIN"
                        }
                     ]
                  }
               ],
               "_android:name": "CombinedBookmarkHistoryActivity",
               "_android:label": "@string/bookmarks",
               "_android:excludeFromRecents": "true",
               "_android:launchMode": "singleTop",
               "_android:configChanges": "orientation|keyboardHidden",
               "_android:theme": "@style/BookmarkTheme"
            },
            {
               "_android:name": "BrowserBookmarksPage",
               "_android:label": "@string/bookmarks",
               "_android:launchMode": "singleTop",
               "_android:configChanges": "orientation|keyboardHidden"
            },
            {
               "_android:name": "BrowserDownloadPage",
               "_android:label": "",
               "_android:configChanges": "orientation|keyboardHidden"
            },
            {
               "_android:name": "BrowserPreferencesPage",
               "_android:label": "@string/menu_preferences",
               "_android:configChanges": "orientation|keyboardHidden"
            },
            {
               "_android:name": "BrowserHistoryPage",
               "_android:label": "",
               "_android:configChanges": "orientation|keyboardHidden"
            },
            {
               "_android:name": "WebsiteSettingsActivity",
               "_android:label": "",
               "_android:configChanges": "orientation|keyboardHidden"
            },
            {
               "intent-filter": [
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.SEARCH"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        }
                     ]
                  }
               ],
               "meta-data": {
                  "_android:name": "android.app.searchable",
                  "_android:resource": "@xml/bookmarks_searchable"
               },
               "_android:name": "BookmarkSearch",
               "_android:label": "@string/bookmarks_search",
               "_android:stateNotNeeded": "true",
               "_android:theme": "@android:style/Theme.NoDisplay",
               "_android:excludeFromRecents": "true"
            },
            {
               "intent-filter": [
                  {
                     "action": [
                        {
                           "_android:name": "android.intent.action.INSERT"
                        }
                     ],
                     "category": [
                        {
                           "_android:name": "android.intent.category.DEFAULT"
                        }
                     ],
                     "data": [
                        {
                           "_android:mimeType": "vnd.android.cursor.dir/bookmark"
                        }
                     ]
                  }
               ],
               "_android:name": "AddBookmarkPage",
               "_android:label": "Save bookmark",
               "_android:theme": "@android:style/Theme.Dialog",
               "_android:configChanges": "orientation|keyboardHidden",
               "_android:windowSoftInputMode": "stateHidden"
            }
         ],
         "activity-alias": {
            "intent-filter": [
               {
                  "action": [
                     {
                        "_android:name": "android.intent.action.CREATE_SHORTCUT"
                     }
                  ],
                  "category": [
                     {
                        "_android:name": "android.intent.category.DEFAULT"
                     }
                  ]
               }
            ],
            "_android:name": "ShortcutBookmarksPage",
            "_android:targetActivity": "BrowserBookmarksPage",
            "_android:label": "@string/shortcut_bookmark",
            "_android:icon": "@drawable/ic_launcher_shortcut_browser_bookmark"
         },
         "meta-data": {
            "_android:name": "android.app.default_searchable",
            "_android:value": ".BrowserActivity"
         },
         "receiver": {
            "intent-filter": [
               {
                  "action": [
                     {
                        "_android:name": "android.intent.action.DOWNLOAD_NOTIFICATION_CLICKED"
                     },
                     {
                        "_android:name": "android.intent.action.DELETE"
                     }
                  ],
                  "data": [
                     {
                        "_android:scheme": "content",
                        "_android:mimeType": "vnd.android.cursor.item/download"
                     }
                  ]
               }
            ],
            "_android:name": ".OpenDownloadReceiver"
         },
         "_android:name": "Browser",
         "_android:label": "@string/application_name",
         "_android:icon": "@drawable/ic_launcher_browser",
         "_android:backupAgent": ".BrowserBackupAgent",
         "_android:taskAffinity": "android.task.browser"
      },
      "_xmlns:android": "http://schemas.android.com/apk/res/android",
      "_package": "com.android.browser"
   }
}
How to make that from a button (e.g. like a button) then set the default browser so that Android understands the whole thing?

Alan Hendry

unread,
Apr 16, 2023, 9:40:58 AM4/16/23
to DroidScript
HI,
To invoke the default browser requires 
app.SendIntent(null, null,
"android.intent.action.MAIN",
"android.intent.category.APP_BROWSER")
So to be eligible to be the default browser I guess we'd need to filter for
action main and category app_browser
Regards, ah

Oarabile Koore

unread,
Apr 27, 2023, 11:14:20 AM4/27/23
to DroidScript
for this to work we need SET_PREFERRED_APPLICATIONS permission.

Alan Hendry

unread,
Apr 27, 2023, 12:17:48 PM4/27/23
to DroidScript
HI,
Not sure if you mean the DS team need to add that permission when building the app
/Sys/app.js seems to read your code and determine the needed permissions.
Not sure what is code we'd need.
I tried adding action main and category app browser to the build.json
but the builder gives me an error (not sure about the format to use).
Regards, ah 

Oarabile Koore

unread,
Apr 27, 2023, 12:28:31 PM4/27/23
to DroidScript
ive been tryin to add this suggestion to my own browser but i cant find a proper solution

Oarabile Koore

unread,
Apr 27, 2023, 12:30:18 PM4/27/23
to DroidScript
im sure we would do this:
{
  "android": {
    "intentFilters": [
      {
        "action": "android.intent.action.VIEW",
        "category": [
          "android.intent.category.DEFAULT",
          "android.intent.category.BROWSABLE"
        ],
        "data": [
          {
            "scheme": "http"
          },
          {
            "scheme": "https"
          }
        ]
      }
    ]
  }
}

//java
var intent = app.CreateIntent("android.intent.action.VIEW", "http://www.example.com");
intent.SetFlags("FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_CLEAR_TASK");
app.StartActivity(intent, "Set as default browser?");

Oarabile Koore

unread,
Apr 27, 2023, 1:14:39 PM4/27/23
to DroidScript
I think In the next droidscript update we should have a feature like advanced editing instead of the build.json we should be able to handle the AndroidManifest.xml

Alan Hendry

unread,
Apr 29, 2023, 8:07:57 AM4/29/23
to DroidScript
HI,
DS currently scans your code to compile a list of permissions you need
(if you don't need a permission then you can remove it via the build.json)
Still want that to happen, 
perhaps the builder could process more options and format them for manifest
Regards, ah

Oarabile Koore

unread,
Apr 29, 2023, 8:24:12 AM4/29/23
to DroidScript
I understand that droidscript scans our code, but also having the option to edit the manifest manually will be very helpful or if the build json, we could then add own permision instead of droidscript scanning our code.
Message has been deleted

Thiemo Melhorn

unread,
Apr 29, 2023, 5:01:33 PM4/29/23
to DroidScript
Why can't I get this to work with Droidscript? It would be very nice if the problem can be solved.

Dave

unread,
May 1, 2023, 2:39:07 PM5/1/23
to DroidScript
You can modify the manifest after building an APK using this tool - 

Thiemo Melhorn

unread,
May 1, 2023, 4:52:03 PM5/1/23
to DroidScript
What is all this supposed to do for my problem?

Right2TheV0id

unread,
May 1, 2023, 5:58:35 PM5/1/23
to DroidScript
This tool will allow you to unpack your apk and to be able to edit the AndroidManifest.xml.
This could allow you to put the missing intent-filters to make your application eligible to be a default web browser (in theory).
You then will have to repack (and probably resign) your apk.

Until DroidScript includes the ability to directly make an app eligible to be a default web browser (which could eventually never happen), this is probably your "best choice" (and the only one).
But even if this could allow you to reach your goal (in theory), as I already said the 10/04/2023, this is far from being a trivial task.
And you will have to do it each time you release a new version of your apk.

Alan Hendry

unread,
Jun 23, 2023, 6:20:30 AM6/23/23
to DroidScript
HI,
In a different thread it was said ...
You need to have an equal number of urlScheme, urlHost values as they correspond to each other (like two matching arrays).
In the example below it would match https://example1.com and http://example2.com
{
    "manifest": {
        "urlScheme": "https,http",  
        "urlHost":"example1.com,example2.com"  
    }
}
I think that means to get http and HTTPS for example1 and example2 would require 
 "urlScheme": "https,https,http,http",
Regards, ah

Thiemo Melhorn

unread,
Jul 5, 2023, 5:57:26 PM7/5/23
to DroidScript
It works partially! That is to say that my browser could actually already be selected as default but unfortunately no real result comes out. As soon as I select my web browser, my app is started but without the page that I selected. I have made the screenshot (see photo below).

2023_07_05_23.36.09.jpg

Can someone help me again with code that also tells my browser "open me the page of XY from e.g. in an email"?

Alan Hendry

unread,
Jul 6, 2023, 12:57:36 PM7/6/23
to DroidScript
HI,
We've been looking at this for a while, how did you get it to work?
What kind of links is is it opening?
Have you included the suggestions above,
specifically onData (and whether it should open all tabs were open the last time the app was used)?
Regards, ah

Thiemo Melhorn

unread,
Jul 6, 2023, 4:04:11 PM7/6/23
to DroidScript
I just had another example from someone else and that's why I got it to work that way but haven't figured out how to open links from apps with it yet.

Thiemo Melhorn

unread,
Jul 10, 2023, 1:54:13 PM7/10/23
to DroidScript
How can I make sure that my web browser understands the URLs and then "redirects" me to the correct website? I got an example from Alan but I can't do much with it.

Thiemo Melhorn

unread,
Jul 10, 2023, 4:04:43 PM7/10/23
to DroidScript
The example I got is this:

//Process data sent by other applications.
Function OnData( isStartUp )
{
    //Display the intent data.
    var intent = app.GetIntent();
    if( intent )
    {
        //Extract the main data.
        var s = "action: " + intent.action + "\n";
        s += "type: " + intent.type + "\n";
        s += "data: " + intent.data + "\n\n";

        //Extras extract.
        s += "extras:\n";
        for( var key in intent.extras )
            s += key+": "+intent.extras[key] + "\n";

        app.Alert( s, "OnData" );
    }
}

Alan Hendry

unread,
Jul 14, 2023, 7:05:52 AM7/14/23
to DroidScript
HI,
The first problem is that no-one has shown how to actually make an app the default browser.
In a very few cases intents are issued that we can get.
As far as I can see to test OnData we have to build and install
(if we can do it directly under DS then please tell me how).
Next there is a parameter on named isStartup,
presumably a Boolean set to true if the app was closed and has been opened by an intent
so the intent data probably needs storing until it can be used
(after set up)
Conversely it is false if the app was already open
in which case the processing depends on the exact state of the app
Also it has been reported that there are differences between Android versions.
Regards, ah
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
0 new messages