-
Hi all, I've been looking for a way to add a hyperlink that is clickable and will launch in the web browser. Is there a built in way of doing that? Is it in the works? (I would like to have it run on android so that might complicate things a bit...) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
You would need to do it in Rust code. In my app Tomotroid I have a Hyperlink object I created you can look at or use. I'm not sure if the Rust crate works on Android though, I never looked. |
Beta Was this translation helpful? Give feedback.
-
I was on mobile early when I wrote that, but coming back to give a bit more detailed answer. The Hyperlink Slint object can be seen here. The Rust code for it is:
utilizing the Rust crate Open, which opens a URL or file path in the default Application for the OS. The crate makes mention of Linux, Mac, and Windows. It makes no mention one way or the other about Android. Having never done Android development, I'm not really sure what would be involved to make it work on the Rust side for Android. |
Beta Was this translation helpful? Give feedback.
Ok so the open crate doesn't really have dedicated android code, which mean they basically attempt to run terminal commands like on linux but you need high permissions to do that from an app.
The proper way to do it on Android is to use what's called ACTION_VIEW intents that can trigger opening of other apps. The crate webbrowser uses those and thus manages to open links even in apps without any permissions. It is fully crossplatform and super useful!
On android and IOS it is restricted to http though (for safety and error handeling I guess) but using their code without the http validation allowed me to open mailto links as well.