Recently, the Google Play store updated its requirements so the target API level of 26 was used to get new apps submitted. While this was reasonably easy to achieve through updating the AndroidManifest.Template, the change to the newer API changed the behaviour of my application.
Before the update, I would download a file to the CachePath and then share to a public folder. I would then get a URI for the public folder path file and share via Intents. Following the update, this no longer worked. After a little research, I discovered this was due to the changes in the Android security system, that actually, make a lot of sense. Rather than sharing the file outside the application, you now provide tempory access to it via the Intent. To achieve this, you need to setup a Provider, (this is done via XML) and then programmatically provide the path as a ‘content://’ URI, set flags for allowing read / write access via the intent and share it.
The video shows how to achieve this and demo’s the working code. To help, below are some of the XML blocks you will need upon the way.
Add this to the AndroidManifest.template in the source code root folder, before the </application> tag. This is then used to build all Android apps.
Create a fileprovider.xml (or whatever file name you set in android:resource when declaring the provider).
<?xml version="1.0" encoding="utf-8"?>
<cache-path name="bbresources" path="bbresources/"/>
More flags and details for Provider Files can be found on the Android documentation
The post Opening a PDF on Android with Delphi appeared first on Stephen Ball's Technical Blog.
Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder. Design. Code. Compile. Deploy.
Start Free Trial
Free Delphi Community Edition
Free C++Builder Community Edition