Use LaunchUriAsync on windows. This works more reliably than issuing a start <URI> command.
Use LaunchUriAsync on windows.
LaunchUriAsync
This works more reliably than issuing a start <URI> command.
start <URI>
robius-open
This crate provides easy Rust interfaces to open URIs across multiple platforms, including:
NSWorkspace
android/content/Intent
xdg-open
start
UIApplication
URIs take many different forms: URLs (http://), tel:, mailto:, file://, and more (see the official list of schemes).
http://
tel:
mailto:
file://
use robius_open::Uri; Uri::new("tel:+61 123 456 789") .open() .expect("failed to open telephone URI");
use robius_open::Uri; Uri::new("http://www.google.com") .open() .expect("failed to open URL");
To use this crate on Android, you must add the following to your app manifest:
<uses-permission android:name="android.permission.QUERY_ALL_PACKAGES" tools:ignore="QueryAllPackagesPermission" /> <queries> <intent> <action android:name="android.intent.action.MAIN" /> </intent> </queries>
or alternatively, disable the android-result feature.
android-result
However, disabling this feature will make Uri::open() always return Ok, regardless of whether the URI was successfully opened.
Uri::open()
Ok
©Copyright 2023 CCF 开源发展委员会 Powered by Trustie& IntelliDE 京ICP备13000930号
robius-open
This crate provides easy Rust interfaces to open URIs across multiple platforms, including:
NSWorkspace
)android/content/Intent
)xdg-open
)start
)UIApplication
)URIs take many different forms: URLs (
http://
),tel:
,mailto:
,file://
, and more (see the official list of schemes).Examples
Android usage
To use this crate on Android, you must add the following to your app manifest:
or alternatively, disable the
android-result
feature.However, disabling this feature will make
Uri::open()
always returnOk
, regardless of whether the URI was successfully opened.