Allow specific app for opening links

7,473 views
Skip to first unread message

Chisan Gelu

unread,
Jul 25, 2022, 2:17:39 PM7/25/22
to DroidScript
Hi.
Is there a method prompt the use allowing openings links by my app ..... ???
May be with SendIntent ???

This setting can be done manually....by it is much better to be done from code...


My app already has uri schema who works.....

Chisan Gelu

unread,
Jul 26, 2022, 1:38:32 AM7/26/22
to DroidScript

I want when user open my app first time to open settings here an prompt user to do check
Open Supported Links !!!
Screenshot_2022-07-26_083408.jpg

Right2TheV0id

unread,
Jul 26, 2022, 5:46:04 AM7/26/22
to DroidScript
The closer I can get is to open the "default apps" settings page:
app.SendIntent( null, null, "android.settings.MANAGE_DEFAULT_APPS_SETTINGS" );
From here you're just "2 clics" away.

Alan Hendry

unread,
Jul 26, 2022, 6:55:38 AM7/26/22
to DroidScript
HI,
In Android 11 (go) I see Settings > Apps  & Notifications > Advanced > Default Apps (browser ...)
and > opening links.
has a list of intents for opening specific settings screens (including ACTION_MANAGE_DEFAULT_APPS_SETTINGS)
 If I to open a specific app (optionally passing it parameters) then I usually search the web for INTENT APP-NAME
(documentation is usually for Java/Kotlin so some translation/guesswork is necessary for DS).
Regards, ah

Alan Hendry

unread,
Jul 26, 2022, 7:29:26 AM7/26/22
to DroidScript
HI,
If DS is displaying a webpage, then you should be able to interact with it Execute
(2.51 is in Beta testing and includes Func to make it easier to call functions).
You could modify the href of links, or intercept the close/unload when a link is touched
Regards, ah
Message has been deleted

Chisan Gelu

unread,
Jul 26, 2022, 3:52:39 PM7/26/22
to DroidScript
What i want is this: When app starts for first time....go here: Settings->Apps->(my app('distanta' in my case)->Set As Default  ....here user can check  ----- Open supported links -----



On Tuesday, July 26, 2022 at 10:34:15 PM UTC+3 Chisan Gelu wrote:
How about opening settings for an explicit app.....????

I tried this .... 
app.SendIntent( "com.myname.distanta", null, "android.intent.action.APPLICATION_PREFERENCES");

but didn.t work ....

Chisan Gelu

unread,
Jul 26, 2022, 4:22:36 PM7/26/22
to DroidScript
I found this .....but didn't succeded to work it....



ACTION_APP_OPEN_BY_DEFAULT_SETTINGS
Added in API level 31
public static final String ACTION_APP_OPEN_BY_DEFAULT_SETTINGS

Activity Action: Show the "Open by Default" page in a particular application's details page.

In some cases, a matching Activity may not exist, so ensure you safeguard against this.

Input: The Intent's data URI specifies the application package name to be shown, with the "package" scheme. That is "package:com.my.app".

Output: Nothing.

Constant Value: "android.settings.APP_OPEN_BY_DEFAULT_SETTINGS"

Chisan Gelu

unread,
Jul 26, 2022, 4:26:17 PM7/26/22
to DroidScript

After the user understands what your app is asking them to do, make the request. To do so, invoke an intent that includes the ACTION_APP_OPEN_BY_DEFAULT_SETTINGS intent action, and a data string matching package:com.example.pkg for the target app, as shown in the following code snippet:

val context: Context = TODO("Your activity or fragment's Context")
val intent = Intent(Settings.ACTION_APP_OPEN_BY_DEFAULT_SETTINGS,
    Uri.parse("package:${context.packageName}"))
context.startActivity(intent)

When the intent is invoked, users see a settings screen called Open by default. This screen contains a radio button called Open supported links, as shown in figure 1.

When the user turns on Open supported links, a set of checkboxes appear under a section called Links to open in this app. From here, users can select the domains that they want to associate with your app. They can also select Add link to add domains, as shown in figure 2. When users later select any link within the domains that they add, the link opens in your app automatically.

Figure 1. System settings screen where users can choose which links open in your app by default.
Figure 2. Dialog where users can choose additional domains to associate with your app.






Can anybody "translate" this approach to DroidScript   ????

Right2TheV0id

unread,
Jul 26, 2022, 7:20:16 PM7/26/22
to DroidScript
The following code works well for me (for application details):
app.SendIntent( null, null, "android.settings.APPLICATION_DETAILS_SETTINGS", null, "package:" + app.GetPackageName() );
This is because this intent is available from API 9.

So this one should work also:
app.SendIntent( null, null, "android.settings.APP_OPEN_BY_DEFAULT_SETTINGS", null, "package:" + app.GetPackageName() );
But it is available for API 31+, so using it with older android yield this:
WARNING: App.SendIntent() failed! (No Activity found to handle Intent { act=android.settings.APP_OPEN_BY_DEFAULT_SETTINGS dat=package:com.smartphoneremote.androidscriptfree })

I have no android 12 (api 31) to test it.

Dave

unread,
Aug 2, 2022, 3:41:07 PM8/2/22
to DroidScript
Not sure if this is helpful in your situation... but you can specify a manifest entry for your app so that it intercepts certain url patterns.  

This is done using a build.json file with the 'urlHost' and 'urlPathPrefix' options.



Reply all
Reply to author
Forward
0 new messages