python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

Add optional android fileprovider.

Open Fak3 opened this issue 6 years ago • 8 comments

https://developer.android.com/reference/android/support/v4/content/FileProvider

If the option --fileprovider-paths=./mypaths.xml is given, then this xml file is copied to apk res/xml/file_paths.xml and <provider> is added to the AndroidManifest.xml

Fak3 avatar Jul 15 '19 09:07 Fak3

Has this been ignored and abandoned, or has anything similar made its way in? Struggling to have my kivy app open an external app.

sanderland avatar Feb 15 '20 16:02 sanderland

Flagging that we are using this support as well and it would be nice if we could get it merged! :)

kollivier avatar Apr 25 '20 19:04 kollivier

I'm trying to share a file on Android 10, which seems pretty basic functionality.

But permissions means I need to create a 'content' Uri rather than a 'file' Uri.

Seems the only way to do this is via a ContentProvider such as FileProvider, but this requires androidx.

So

  1. This is really important, file 'share' is basic functionality. Thank you.
  2. Consider defaults for the xml files, a Python user is here because they don't want to think about that stuff.
  3. The Android docs say ContentProvider must be sub classed, but anything I try to do in pyjnius wont be seen in Java. And if I try to instance ContentProvider, I get: JNI DETECTED ERROR IN APPLICATION: can't make objects of type android.content.ContentProvider: 0x712ee630 So a minimal Python/pyjnius example would be really helpful.

Thanks again.

RobertFlatt avatar May 28 '20 04:05 RobertFlatt

@Fak3 thank you for the pull request and sorry that it wasn't reviewed earlier. Thanks also to the other to show interest regarding the feature. Before we can merge it could you address the following?

  • rebase to recent upstream/develop changes
  • leverage android.gradle_dependencies refs https://github.com/kivy/python-for-android/pull/2200#issuecomment-637435022
  • write unit tests

Ideally squash the commits after addressing so the PR is still one commit

AndreMiras avatar Jun 02 '20 11:06 AndreMiras

Seems to be a must API 30 onwards. More restrictions by Google now on using storage

wajdyz avatar Sep 11 '20 23:09 wajdyz

Unfortunately the original branch has conflicts with the develop branch of p4a. I rebased it on top of the latest version (6ed70232) and published the rebased branch here: https://github.com/antocuni/python-for-android/tree/fileprovider-rebased

See also this example to see it in action: https://github.com/antocuni/plyer_camera_example

antocuni avatar Oct 12 '21 09:10 antocuni

@Fak3 Any word on resolving the conflicts? Would be nice to get this in.....

Zen-CODE avatar Apr 30 '22 23:04 Zen-CODE

There is another way to generate a uri : uri = context.getContentResolver().insert()

Android-for-Python avatar May 01 '22 02:05 Android-for-Python