openurl don't work with Android 11 and higher

I write in this new topic because I have the same problem reported by other developers with the system.openURL() function for Android versions with API 30 onwards (Android 11).

From my App, compared to before, I can no longer open a pdf document downloaded in my system.DocumentsDirectory

It seems to be a permissions issue but I don’t know what to do.
I’ve tried with various configurations on build.settings but it doesn’t seem to work.

It’s very important, I think not only for me, can someone help me?..

Thank you

It is working on myside

Just make sure your URL is legit

can you share the URL?

Hi kakula,
thanks for replying.

I’m sure the urls are correct because they are the same ones that worked before. These are PDFs physically downloaded onto my mobile phone which I then cannot open through other PDF Apps.
Also the iOS version of the app that uses the same urls works fine.

Have you set any particular usesPermissions on build.settings to access the files inside the device?.. do you use Solar2D Native or the Lua-only version?..

Thank you

if the URL is meant to download the pdf, then it is better if you use then open the files
because if the URL is a pdf it should open with the default app for that weather it is a browser or a native app on your phone —As far as I know—

I download PDFs regularly from my site with
The problem is then only in the display.
In API versions < 30 I invoked the system.openUrl() function and it opened the documents on my smartphone via any other external App, but now with API >= 30 nothing happens. Better said, the external App opens for a moment and then closes instantly, or it gives an error and doesn’t open it.
From what I have read on the web, it is a common problem of permissions that must be set to be able to open documents stored on your smartphone via third-party apps and therefore allow them to access the document folder created by my App.

In the guide and in the Api Reference, however, I have not found anything to solve the problem unfortunately. :sleepy:

did you try this/

Can you confirm that issue started at Android 11, not the recent Android 13?
Maybe we need a new API to expose createContentUriForFile() for sharing file to other Applications.

I don’t know if it’s related or not but my apps which were working before now can not open html files from system.DocumentsDirectory using native.newWebView(). It has not been for the last 2 years but the latest builds shows net::ERR_ACCESS_DENIED error. I have checked the documentation in case it might be changed but it’s the same.

Yes, the problem occurred starting from Android 11 (API 30).

It worked normally before.

Unfortunately I don’t think I can implement the function you indicated to me because I don’t use the native mode but the classic one (LUA only). More than anything, I don’t know how to implement it without revolutionizing the entire project. :sleepy:

Thanks anyway.

Yes, I think it is a problem with new permissions for access to internal files related to API 30 or higher.

They talked about it in this topic and I think they found the solution:
Android API level 30 is here in 3651 - Getting Started / Announcements - Solar2D Game Engine

Unfortunately this does not apply to the system.openUrl() function.

Thanks a lot. It worked and now I am building the app to upload to the PlayMarket!

1 Like

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.