def _choose_image(self, on_complete, filename=None): assert(on_complete is not None) self.on_complete = on_complete self.filename = filename activity.unbind(on_activity_result=self.on_activity_result) activity.bind(on_activity_result=self.on_activity_result) intent = Intent(Intent.ACTION_PICK) intent.setType("image/jpeg") intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, True) #intent.putExtra(Intent.EXTRA_LOCAL_ONLY, True) #intent.putExtra(Intent.CATEGORY_OPENABLE, True) PythonActivity.mActivity.startActivityForResult( Intent.createChooser(intent, autoclass( 'java.lang.String')("Select Picture")), 0x100)
def _choose_image(self, on_complete, filename=None): assert (on_complete is not None) self.on_complete = on_complete self.filename = filename activity.unbind(on_activity_result=self.on_activity_result) activity.bind(on_activity_result=self.on_activity_result) intent = Intent(Intent.ACTION_PICK) intent.setType("image/jpeg") intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, True) #intent.putExtra(Intent.EXTRA_LOCAL_ONLY, True) #intent.putExtra(Intent.CATEGORY_OPENABLE, True) PythonActivity.mActivity.startActivityForResult( Intent.createChooser( intent, autoclass('java.lang.String')("Select Picture")), 0x100)
from plyer.facades import Gallery import jnius from android import activity from android import autoclass import threading from time import sleep Intent = autoclass('android.content.Intent') PythonActivity = autoclass('org.renpy.android.PythonActivity') Uri = autoclass('android.net.Uri') CompressFormat = autoclass('android.graphics.Bitmap$CompressFormat') BitmapFactory = autoclass('android.graphics.BitmapFactory') FileInputStream = autoclass('java.io.FileInputStream') FileOutputStream = autoclass('java.io.FileOutputStream') BufferedOutputStream = autoclass('java.io.BufferedOutputStream') ContentResolver = PythonActivity.mActivity.getContentResolver() Version = autoclass('android.os.Build$VERSION') class AndroidGallery(Gallery): def _choose_image(self, on_complete, filename=None): assert (on_complete is not None) self.on_complete = on_complete self.filename = filename activity.unbind(on_activity_result=self.on_activity_result) activity.bind(on_activity_result=self.on_activity_result) intent = Intent(Intent.ACTION_PICK) intent.setType("image/jpeg") intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, True) #intent.putExtra(Intent.EXTRA_LOCAL_ONLY, True)
from plyer.facades import Gallery import jnius from android import activity from android import autoclass import threading from time import sleep Intent = autoclass('android.content.Intent') PythonActivity = autoclass('org.renpy.android.PythonActivity') Uri = autoclass('android.net.Uri') CompressFormat = autoclass('android.graphics.Bitmap$CompressFormat') BitmapFactory = autoclass('android.graphics.BitmapFactory') FileInputStream = autoclass('java.io.FileInputStream') FileOutputStream = autoclass('java.io.FileOutputStream') BufferedOutputStream = autoclass('java.io.BufferedOutputStream') ContentResolver = PythonActivity.mActivity.getContentResolver() Version = autoclass('android.os.Build$VERSION') class AndroidGallery(Gallery): def _choose_image(self, on_complete, filename=None): assert(on_complete is not None) self.on_complete = on_complete self.filename = filename activity.unbind(on_activity_result=self.on_activity_result) activity.bind(on_activity_result=self.on_activity_result) intent = Intent(Intent.ACTION_PICK) intent.setType("image/jpeg") intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, True)
from android import mActivity, autoclass, activity from threading import Thread from storage import SharedStorage Intent = autoclass('android.content.Intent') # Source https://github.com/RobertFlatt/Android-for-Python/share_rcv ''' NOTE: intent_filter.xml and intent_handler() must be customized according to the file types handled by the app. The intent_filter tells Android what data types this app can handle The intent_handler passes the shared data to the app. READ: https://developer.android.com/training/sharing/receive#handling-content ./intent_filter.xml <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="text/plain" /> </intent-filter> <intent-filter> <action android:name="android.intent.action.SEND" /> <category android:name="android.intent.category.DEFAULT" /> <data android:mimeType="video/mp4" /> </intent-filter> '''
from android import mActivity, autoclass, cast from os.path import splitext, join, basename, exists from os import mkdir FileOutputStream = autoclass('java.io.FileOutputStream') FileInputStream = autoclass('java.io.FileInputStream') FileUtils = autoclass('android.os.FileUtils') Environment = autoclass('android.os.Environment') MediaStoreFiles = autoclass('android.provider.MediaStore$Files') MediaStoreAudioMedia = autoclass('android.provider.MediaStore$Audio$Media') MediaStoreImagesMedia = autoclass('android.provider.MediaStore$Images$Media') MediaStoreVideoMedia = autoclass('android.provider.MediaStore$Video$Media') MediaStoreDownloads = autoclass('android.provider.MediaStore$Downloads') MediaStoreMediaColumns = autoclass('android.provider.MediaStore$MediaColumns') ContentValues = autoclass('android.content.ContentValues') MimeTypeMap = autoclass('android.webkit.MimeTypeMap') JString = autoclass('java.lang.String') Uri = autoclass('android.net.Uri') ContentUris = autoclass('android.content.ContentUris') # Source https://github.com/RobertFlatt/Android-for-Python/storage ######################### # assumes api>=29 # api=30 recomended ######################### class SharedStorage: # For shared media, documents, and downloads ############################################