I've used this to share files created by my app, and it has worked flawlessly on my Pixel XL running Android 7.1.2 ... until now! All of a sudden, initiating sharing does nothing. So, I went back to Erel's original example and installed that. But even that no longer works.
So then I tried both my app and Erel's example on my wife's Nexus 5x, also running Android 7.1.2. Both worked perfectly. Nexus 5x yes, Pixel XL no.
Has anyone else encountered anything similar? Unless it's because the latest patches for Android 7.1.2 for the Pixel XL has a problem, I'm stumped. (Just installed the latest patch ... same problem.) I would appreciate it if someone with a Pixel XL downloaded Erel's example above and tried it, to see if it works on their unit.
Yes, I just did, running the ShareFileWithFileProvider example in debug mode. After tapping Share and breaking on Button1_Click, I can step through all lines without generating any log messages at all, and the share screen never appears.
Do you think it's possible for some other app to disable operation of FileProvider?
Erel, thanks for this suggestion, which SOLVES my problem! My Button1_Click code (in ShareFileWithFileProvider) is now:
B4X:
Sub Button1_Click
'copy the file to the shared folder
File.Copy(File.DirAssets, "1.bal", Starter.shared, "1.bal")
Dim in As Intent
in.Initialize(in.ACTION_SEND, "")
in.SetType("text/plain") 'it is not related to the file itself.
in.PutExtra("android.intent.extra.STREAM", CreateFileProviderUri(Starter.shared, "1.bal"))
in.Flags = 1
in.WrapAsIntentChooser("Select Sharing Service ...")
StartActivity(in)
End Sub
When I remove the WrapAsIntentChooser line (your original version), the app doesn't work on my Pixel XL. When I include it, it works like it should.