Android Question Problems with PDF on Samsung Tab A7 Lite

Brad Henderson

Member
Licensed User
Hello,

Just hoping someone has had a similar problem with Samsung Tab A7 lite. I have a B4A app running well on a Samsung Tablet T550 with Android 7.1.1. Have bought a more recent Tab A7 lite and when running the app on this device, two significant things have happened:
1. The pdf report that the app produces using PdfDocument, which appears perfect under Android 7.1.1 is totally misaligned under Android 14. Although the screen is obviously a different size the pdf when read on my PC is still incorrect. So I am thinking it has not been created correctly.
2. I can create pdf files (although they not formatted correctly) in the internal storage under internal storage>Android>data>"app Package">files however my pdf reader (AVR-Apps "PDF Viewer lite" cannot access these files with "cannot open document". Under the devices setting on the older Tablet I set the permissions to include storage, however on the newer Table there doesn't appear to be this option?

I know this is not a B4A specific problem, but I am hoping with the vast experience of this form someone may have come across these issues.

Thanks for your help
Brad
 

MicroDrie

Well-Known Member
Licensed User
Longtime User
Regarding being able to write and read from an extra memory card under the current version of Android, I would first test whether this advice from Erel works when you have correctly installed the most recent B4A version: SaveAs - Let the user select a target folder + list of other related methods

If this example works on the new device, create a new B4XPages project and place your existing B4A program code in it, check and upgrade to the latest library versions if necessary, so that all possible changes and improvements in B4A and the Android environment are included.

Once you've done that, what are the remaining problems?
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
1. The pdf report that the app produces using PdfDocument, which appears perfect under Android 7.1.1 is totally misaligned under Android 14. Although the screen is obviously a different size the pdf when read on my PC is still incorrect. So I am thinking it has not been created correctly.
You can try the "recent" [B4X] PDF Generator - B4X Cross Platform - Class 100% B4X Code library to see if it meets your requirements and working well on your devices.
 
Upvote 0

Brad Henderson

Member
Licensed User
Thank you MicroDrie,
1. I did find the PDFgen link helpful. I found I was placing items on the pdf document using "dip" as part of the location, which worked in the 10" screen but went haywire with the smaller screen on the A7. Once I removed the dips it worked.
Regarding being able to write and read from an extra memory card under the current version of Android
The problem is not being able to read and write to an extra memory card. It is that in Android 14 (and 12,13 I think) the o/s doesn't give access to the internal storage. When I try to open a pdf file in "internal storage>Android>data>"app Package">files" (which my B4A app saves to) the pdf viewer says "cannot open document". I save to that location by using:
Get Folder:
Public Sub GetDBFolder As String
#If B4A
    Dim rp As RuntimePermissions   
    If File.ExternalWritable Then Return rp.GetSafeDirDefaultExternal("") Else Return File.DirInternal
#Else If B4i
    Return File.DirDocuments
#End If
End Sub
Is there some other location that I should be saving these pdf files to so later Android versions can access them?

Thanks for your help.
Brad
 
Upvote 0

MicroDrie

Well-Known Member
Licensed User
Longtime User
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0

Brad Henderson

Member
Licensed User
Thank You DonManfred
I have looked at the example and can see how to write to a txt file and read it with a third party app but I cannot work out how to to write the pdf to the Provider.SharedFolder?
B4X:
Dim out As OutputStream = File.OpenOutput(Provider.SharedFolder, FileName, False)
    pdf.WriteToStream(out)
    out.Close

But Log says - java.io.FileNotFoundException: TestPDF.pdf: open failed: EROFS (Read-only file system)
Your assistance is appreciated.

Brad
 
Upvote 0

Brad Henderson

Member
Licensed User
Upload a small project showing the issue.
Noone can help with this - LESS - information you provide.
Thanks DonManfred,
When I started to minimise my app down to a simple app to show what was happening it stopped happening and now it works. So don't know what was wrong but it is working now using the example above.

Thanks again
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
When I started to minimise my app down to a simple app to show what was happening it stopped happening and now it works.
This happens 83;76% of the time, that’s why so important to upload a small project ?
 
Upvote 0
Top