Many thanks again JohnC. Using your example and Erel's "takeScreenshot" subroutine I succeeded in creating a bitmap of the graph shown above and saving that as a JPEG file to the File.DirInternal directory for my App. Just a few lines of code. However, when trying to attach the .JPEG to an e-mail I find that GMail denies access to the DirInternal folder. It is only GMail that won't attach it - an older tablet will happily list the Chart.jpg file as an attachment, but in that case (even though the Google e-mail account is correctly specified) GMail will not allow that old e-mail app to 'sign in'. (Seems odd that Google denies access to its own Android directory while allowing older e-mail apps to extract files from it, but I'm too old to be surprised at anything now.)
Trying to copy the file to DirDefaultExternal or DirRootExternal fails with a "FileNotFoundException" error and PermissionDenied when trying to open the target, even after confirming write access with File.ExternalWritable. For the simple routine below to prove so error-prone I am beginning to doubt my logic!
Log("Copying file to external(emulated)")
File.Copy(File.DirInternal,"chart.jpg",File.DirRootExternal,"graph.jpg")
Log("Copied out")
I think the principle is right and offers a solution, but access to files should be simpler than this. Any thoughts would be very welcome.
Very Best, David
FileProvider usage is demonstrated here: https://www.b4x.com/android/forum/threads/class-fileprovider-share-files.97865/One worry is I can't find anything about the FileProvider class in the documentation
This is not accurate. XUI.FileURI returns a url to a file resource. This is all that it does. It is useful for example, when you want to show a local html file in WebView.if the XUI call for a FileUri is indeed a valid function, what use is it if the resulting Uri fails for Android 7 and upwards?
I think to fix this issue, you will first need to make your app be a "File Provider":
[class] FileProvider - share files
Edit: FileProvider is included as an internal library now. After investigating several issues with the current FileProvider code that you can find in the forum, I decided to make some improvements and implement it in a class. Starting from Android 7 (API 24) you cannot directly share file uris...www.b4x.com
Then instead of specifying a file "directory" to gmail for the attachment, you will instead provide the "FileURI" of the file to Gmail:
[Solved] [Class] Send E-Mail with FileproviderURI
Hello, According to the post https://www.b4x.com/android/forum/threads/class-send-e-mail-with-fileprovideruri.89217/ I would like to send the email in HTML format. I modified where it says EmailIntent.SetType ("text / plain") by EmailIntent.SetType ("text / html"). But it is not interpreting...www.b4x.com
That's another good tip - thanks again JohnC. Am in the middle of writing the manual, but I'll certainly be refining these attachments as I get more used to the possibilities. I managed to get some semblance of control so far, but your suggestion gives me more options. I'll certainly pursue it. Also emexes note about HTML and the possibilities for transfer to spreadsheet will need a good look. All I need now is time!!And if you want to crop the image (for example to get rid of the "EMAIL" button at the bottom of the image) to produce a more focused image attachment, I just came across this thread:
Only rectangle area of a bitmap
I need for displaying track volume 9 different states of a bitmap from "silent" to loud". You can see here different states on the right side of the screeshot Normaly I would paint one Image, Save it as PNG In the App I load it into a BITMAP and then copy only a rectangle part of it to the view...www.b4x.com
Great idea again - time is all I need!A thought in favor of sending the table in HTML format, is that the receiver can then easily copy-paste parts or all of it into a spreadsheet, and it will (well: should) retain the row/column structure.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?