Android Question ShareFileWithFileProvider no longer works on Pixel XL (?) [SOLVED]

Andris

Active Member
Licensed User
Longtime User
Erel posted an example of how to share any file in ShareFileWithFileProvider.zip, found here:
https://www.b4x.com/android/forum/threads/share-txt-files.73166/#post-464921

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.
 
Last edited:

Andris

Active Member
Licensed User
Longtime User
Have you checked the unfiltered logs for any relevant messages?

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?
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Yes, I just did, running the ShareFileWithFileProvider example in debug mode
this is not what erel expected.
Run it in Release mode and look at the unfiltered log.
 
Upvote 0

Andris

Active Member
Licensed User
Longtime User
this is not what erel expected.
Run it in Release mode and look at the unfiltered log.

OK thanks Don. When I do that, I get the following, with first 3 lines on startup and then 2 lines on each tap of the Share button:

B4X:
** Activity (main) Pause, UserClosed = true **
** Activity (main) Create, isFirst = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (main) Resume **
 
Upvote 0

Andris

Active Member
Licensed User
Longtime User
I've checked this example on Nexus 5X running Android 8 and it works properly.

Try to add In.WrapAsIntentChooser before you call StartActivity.
Maybe the default selected app is not working properly.

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.

Thanks again for your (and DonManfred's) help.
 
Upvote 0
Top