I adapt, 1 1/2 year ago, a QR code reader application from the example found in the forum. Now i want to be able read a business card containg a QR code in vcf file mode. I found an example at https://www.b4x.com/android/forum/threads/insert-a-new-contact-with-a-qrcode-vcard.147894/. QR Code has been successfuly read and save to file in “fp.SharedFolder”, I believe. I get an abend in “fp.GetFileUri”. Maybe the problem is coming from the permissions I don’t give. No Manifest file example has been given in the example. Which permissions should I give in manifest file ?
B4X:
Dim fp As FileProvider
fp.Initialize
File.WriteString(fp.SharedFolder, "vcard.vcf", s)
Log("File vcard has been created...")
'Insert in contacts
Dim thisintent As Intent
thisintent.Initialize(thisintent.ACTION_VIEW,fp.GetFileUri(fp.SharedFolder & "/vcard.vcf"))
thisintent.SetType("text/x-vcard")
thisintent.Flags = 0x01
StartActivity(thisintent)
' Creat vcf file
File.WriteString(Path, "vcard.vcf", YourValue)
' copy to SharedFolder
Dim fp As FileProvider
fp.Initialize
File.Copy(Path, "vcard.vcf", fp.SharedFolder, "vcard.vcf")
'Insert in contacts
Dim thisintent As Intent
thisintent.Initialize(thisintent.ACTION_VIEW,fp.GetFileUri("vcard.vcf"))
thisintent.SetType("text/x-vcard")
thisintent.Flags = 0x01
StartActivity(thisintent)
one minor point: inventing a "success!" log message is not a good idea. if you really want to know if some i/o operation has been successfully carried out, you should use try/catch or - at the very least - test for the existence of the file. if the operation is actually successful, logging that it was successful is irrelevant (there would have been an abend otherwise). in other words, saying something was successful without actually testing for success will come back to bite you, especially in the event of null objects. there will be no error until some later point when you attempt to use the null object (which you didn't actually test when you had a chance, having preferred - instead - to log "success!")