Giter VIP home page Giter VIP logo

storage-samples's Introduction

Storage Samples Repository

This repository contains a set of individual Android Studio projects to help you learn about storage in Android (saving files in storage, key-value data, sharing simple data, sharing files, printing files, content providers, Storage Access Framework [SAF], etc.).

For more information, please read our documentation

storage-samples's People

Contributors

cketti avatar codingjeremy avatar dependabot[bot] avatar emilieroberts avatar ggfan avatar javadude avatar keyboardsurfer avatar kokoro-team avatar mirwisek avatar nic0lette avatar owahltinez avatar thedmail avatar yrezgui avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

storage-samples's Issues

[File Provider] Gray Gallery crashes after Clearing Files

Pressing the "Clear Files" button deletes the Images Folder without it ever being recreated.

This causes a java.io.FileNotFoundException for all the other buttons until the app is relaunched, at which time the Images Folder is recreated again.

I would like to submit a fix.

All Files Permissions in Android 12

Hello,

I have researched how to solve this "issue" in the documentation and on the web, but unfortunately was not able to find anything.
We are currently running the Android 11 In the project I am working on, we have the all files permissions in the code, so everytime the application starts on a new device, it will ask for the permissions. However, in Android 12, instead of displaying only the application that is requesting all files permissions, it displays all the applications when our application is requesting access.

It is important to highlight that our code is following Android's documentation and we are using the ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION

Is there a way to prevent this behaviour just displaying our app's permissions? We want to avoid this behaviour, since users can change the settings for other app's and that's potentially dangerous for our user.

Thanks in Advance

Unable to upload file

android 11 /storage/emulated/0/Download/Driver.apk: open failed: EACCES (Permission denied)

MediaStore doesn't really delete image file

I installed MediaStore V1.0 onto my Android running V10
I selected an image to delete from the images displayed within the app, clicked delete and the image appeared to be deleted. However, when I then opened the phone's default image viewer the image was still there. On opening the file explorer I could still see the file: /storage/sdcard0/DCIM/Camera/IMG_20210119_190148.jpg when viewing by folder, but the image was missing when viewing by image type.
When I returned to the MediaStore app, the file was no longer visible. It therefore appears that some reference to the image file is deleted, and not the actual file.

How to delete multiple audio files from MediaStore ?

I'm trying to delete audio files (that were copied to the device from USB) from the external storage.
After analyzing the MediaStore sample, I ended up with the following solution for API 28 and earlier:

fun deleteTracks(trackIds: LongArray): Int {
    val whereClause = buildWildcardInClause(trackIds.size) // _id IN (?, ?, ?, ...)
    return resolver.delete(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, whereClause, Array(trackIds.size) { trackIds[it].toString() })
}

I noticed that the above code only deletes tracks from the MediaStore database and not from the device (files are re-added to the MediaStore after rebooting). So I modified that code to query the Media.DATA column, then use that information to delete the associated files. This works as intended.

But now that Android Q introduced scoped storage, Media.DATA (and Albums.ALBUM_ART) are now deprecated because the app may be unable to access those files. ContentResolver.openFileDescriptor can only be used to read files, not delete them.

Then what is the recommended way to delete tracks as of Android Q ?
The sample does not show how to delete multiple files from the MediaStore, and MediaStore.Audio.Media seems to work differently than MediaStore.Images.Media.

All the URI returned by system chooser can be read without any permissions?

In the module ActionOpenDocument, there's no PERMISSIONS declared in AndroidManifest.xml.

Does that mean we have the access to all URI returned by system chooser?
Like Intent.ACTION_PICK, Intent.ACTION_GET_CONTENT,Intent.ACTION_OPEN_DOCUMENT etc.

I can not find any official info about this.

What I've implemented is choose an image from gallery then set it to an ImageView.
Tested on several devices it works fine. (Pixel 3 Android 12, Samsung S8 Android 7, ...)
Only one Chinese Model(Android 8.1) crashed and reported SecurityException.

Crash on start Screen in MediaStore sample

2020-03-22 19:34:53.585 23637-23637/com.android.samples.mediastore E/AndroidRuntime: FATAL EXCEPTION: main Process: com.android.samples.mediastore, PID: 23637 java.lang.IllegalStateException: displayName must not be null at com.android.samples.mediastore.MainActivityViewModel$queryImages$2.invokeSuspend(MainActivityViewModel.kt:193) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594) at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)

Title

gh pr checkout 109

Query with relative path

As the title, is there any sample or way that I can query with some relative path?
I know we can do it when inserting, but when searching, can we do the same thing?

Is it normal for functions to be called multiple times in StorageProvider?

I am studying Documents Providers and I have found something that I cannot understand, which also happens with the "StorageProvider" example of this repository.

It appears that all functions are called more than once when I open SAF.

I report the logcat:

When I first open SAF:

2020-05-27 19:57:45.888 20322-20362/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:57:45.971 20322-20362/com.example.android.storageprovider V/MyCloudProvider: queryChildDocuments, parentDocumentId: root: sortOrder: _display_name ASC
2020-05-27 19:57:45.990 20322-20362/com.example.android.storageprovider V/MyCloudProvider: queryChildDocuments, parentDocumentId: root: sortOrder: _display_name ASC
2020-05-27 19:57:46.036 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail
2020-05-27 19:57:46.078 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail
2020-05-27 19:57:46.093 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail
2020-05-27 19:57:46.109 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocumentThumbnail

When I open a file (eg a photo with Google Foto):

2020-05-27 19:58:01.127 20322-20341/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:58:01.273 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.306 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.344 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.345 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.381 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.775 20322-20341/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:58:01.810 20322-20341/com.example.android.storageprovider V/MyCloudProvider: queryDocument
2020-05-27 19:58:01.843 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.849 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.854 20322-20341/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r
2020-05-27 19:58:01.868 20322-20362/com.example.android.storageprovider V/MyCloudProvider: openDocument, mode: r

Is it normal for queryDocument() and openDocument () to be called so many times?
That way, if my document provider were to download a file over the network, wouldn't it be downloaded multiple times?

Feature Request

Use case - Currently I'm working on video uploading module. To get the video i have fired SFA video picker intent but I can't get any way or code to get the video details from uri in OnActivityResult even i have watched Google IO 19 Preparing Scoped Storage Video but there also not provided any sample code how to do that. ( Video details mean duration size name resolution and name )

To get the video details we have to use MediaStore api which recommended one and MediaStore only works with content URIs if i pass file uri then cursor will be always null
and we only get the content uri when cursor isnot null

Hoping to will answer my question someone

FileManager can't open selected files by intent action

I've been following latest documentation and tried to open the files after all permissions check mentioned in the docs. I thought I might be missing something, ergo, after checking the FileManager sample, it seems openFile() extension from FileManager sample is also helpless in opening the file. I tried to open a word file (.docx) an image file, a pdf file. It opens the app but the file can't be found and (Adobe Reader, Word and Gallery shows the main screen).

Tested with Realme 5 Pro (Android 10) with all permissions granted

fun openFile(activity: AppCompatActivity, selectedItem: File) {
    // Get URI and MIME type of file
    val uri = Uri.fromFile(selectedItem).normalizeScheme()
    val mime: String = getMimeType(uri.toString())

    // Open file with user selected app
    val intent = Intent()
    intent.action = Intent.ACTION_VIEW
    intent.data = uri
    intent.type = mime
    return activity.startActivity(intent)
}

Missing appcompat in build.gradle

Issue by diceroll123
Wednesday Aug 19, 2015 at 08:32 GMT
Originally opened as googlearchive/android-StorageProvider#1


It's way too much work to fill out a CLA or anything like that, it's after 4 AM in the morning. My brain's not cut out for that right now.

Though this example is not what I was looking for, just gonna leave this issue here. 😃

Android Studio won't build newest build because it uses AppCompat, try adding compile "com.android.support:appcompat-v7:23.0.0"to the dependencies in the Application build.gradle. 👍

You may have this issue elsewhere that auto-updates builds like this.

Made an issue here because the link under Support is broken.

If you've found an error in this sample, please file an issue: https://github.com/googlesamples/android-MyCloud

queryRecentDocuments method of MyCloudProvider.java have a bug.

Issue by lbtrace
Wednesday Jul 18, 2018 at 09:03 GMT
Originally opened as googlearchive/android-StorageProvider#5


  • Code analysis
Code path: \Application\src\main\java\com\example\android\storageprovider\MyCloudProvider.java

public Cursor queryRecentDocuments(String rootId, String[] projection)
        throws FileNotFoundException {
    ......
    // Create a queue to store the most recent documents, which orders by last modified.
    PriorityQueue<File> lastModifiedFiles = new PriorityQueue<File>(5, new Comparator<File>() {
        public int compare(File i, File j) {
            return Long.compare(i.lastModified(), j.lastModified());
        }
    });
    ......
    // Add the most recent files to the cursor, not exceeding the max number of results.
    for (int i = 0; i < Math.min(MAX_LAST_MODIFIED + 1, lastModifiedFiles.size()); i++) {
        final File file = lastModifiedFiles.remove();
        includeFile(result, null, file);
    }
    return result;
}

In for code segment, lastModifiedFiles.remove() will modify PriorityQueue size, so lastModifiedFiles.size() always change, this is logic error.

Cleaning Ui file list when files are deleted from other app, like file manager.

I am learning android and I seen your example, and I implemented my provider in my first application

https://github.com/DarioLobos/sistemariego

but when I erase files using the file manager In my list of UI files still are showed. I try to clean it using NotifyChanges without any implementation that can update the list For example this.:

 context = root.getContext();

    Uri emptyUri= DocumentsContract.buildRootUri(AUTORITY, EMPTY);

(this Is a root with only the id empty and column MY_TYPE_DIR, trying to clean thelist)

    context.getContentResolver().notifyChange(emptyUri,null);

    Uri rootUri = DocumentsContract.buildRootUri(AUTORITY, ROOT);

    ContentObserver observer = new ContentObserver(null) {
        @Override
                  public boolean deliverSelfNotifications() {
                       return super.deliverSelfNotifications();
                  }
              };

    context.getContentResolver().notifyChange(rootUri,observer);
    context.getContentResolver().registerContentObserver(rootUri,true,observer);
    observer.dispatchChange(true,rootUri);

    Uri documentsInRoot = DocumentsContract.buildSearchDocumentsUri(AUTORITY, ROOT,"");  

I did it in the fragment that use to request the save open file. BUT DONT ERASE THE GOST FILES ERASED FROM FILE MANAGER IN ANY WAY.

Do you have any example to clean the erased files from other apps ? Many thanks in advance.

MediaStore Sample (Can't convert uri to file.. security exception)

I have implemented this sample in my project... Everything was ok but when I try to convert the content uri to File to upload the image to server.. it throws an error.....

Security Exception. In Android 10

If I enable legacy in androidmanifest.xml file then it is ok...

If it shows a security exception why u make this sample recently?

What is the alternative...what is the uses of this sample if i can't use the image I pick?????

Crash on a mobile phone for Android 10

I'm working on a file manager application. When I call API --- File. listFiles() , a crash occurs. Mobile phone manufacturer is vivo -- a china brand.
I had add needed storage permissions for my app, and provide path xml in res folder。

AndroidManifest.xml include the following permissions:
uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"

path xml( file_provider.xml ) like this:

<cache-path
    name="cache"
    path="." />

<!--    应用在被用户卸载后,SDCard/Android/data/应用的包名/ ,这个目录下的所有文件都会被删除-->
<!-- Context.getExternalCacheDir() + "/cache/" -->
<!--    SDCard/Android/data/你的应用包名/cache/目录,一般存放临时缓存数据,比如头像-->
<external-cache-path
    name="sdcard_cache_path"
    path="." />

<!-- Context.getExternalFilesDir(null) + "/path/" -->
<!--    SDCard/Android/data/应用的包名/files/目录   ,一般放一些长时间保存的数据,比如语音,视频,发送的图片,文件-->
<external-files-path
    name="sdcard_file_path"
    path="." />

<!-- 代表Environment.getExternalStorageDirectory() + "/path/" -->
<!-- path设置为'.'时代表整个存储卡 Environment.getExternalStorageDirectory() + "/path/"   -->
<external-path
    name="sdcard_root_path"
    path="." />


<!-- Context.getFilesDir() + "/path/" -->
<!-- 此处为   data/data/包名/files/path -->
<files-path
    name="files"
    path="." />
<!-->应用存储目录<-->
<!--    代表设备的根目录new File("/")-->
<!-- 此处为   ./ -->
<root-path
    name="root_path"
    path="" />

Sample "ContentProviderPagingKotlin" crashes

image

2019-09-08 02:20:34.585 28158-28158/com.example.android.contentproviderpaging E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.android.contentproviderpaging, PID: 28158
java.lang.RuntimeException: Unable to get provider com.example.android.contentproviderpaging.ImageProvider: java.lang.ClassNotFoundException: Didn't find class "com.example.android.contentproviderpaging.ImageProvider" on path: DexPathList[[zip file "/data/app/com.example.android.contentproviderpaging-OXltTdAm2A1a4Aqc-7OZuA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.android.contentproviderpaging-OXltTdAm2A1a4Aqc-7OZuA==/lib/arm64, /system/lib64, /system/product/lib64]]
at android.app.ActivityThread.installProvider(ActivityThread.java:6988)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445)
at android.app.ActivityThread.access$1300(ActivityThread.java:219)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859)
at android.os.Handler.dispatchMessage(Handler.java:107)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7356)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.android.contentproviderpaging.ImageProvider" on path: DexPathList[[zip file "/data/app/com.example.android.contentproviderpaging-OXltTdAm2A1a4Aqc-7OZuA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.android.contentproviderpaging-OXltTdAm2A1a4Aqc-7OZuA==/lib/arm64, /system/lib64, /system/product/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:196)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.AppComponentFactory.instantiateProvider(AppComponentFactory.java:147)
at android.app.ActivityThread.installProvider(ActivityThread.java:6972)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:6528) 
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6445) 
at android.app.ActivityThread.access$1300(ActivityThread.java:219) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) 
at android.os.Handler.dispatchMessage(Handler.java:107) 
at android.os.Looper.loop(Looper.java:214) 
at android.app.ActivityThread.main(ActivityThread.java:7356) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930) 

Cancellation Signal is always null?

Issue by anmolvermamm
Friday Sep 28, 2018 at 13:25 GMT
Originally opened as googlearchive/android-StorageProvider#6


https://github.com/googlesamples/android-StorageProvider/blob/6f21c5616efed8058b9759202ae1c09d2f124821/Application/src/main/java/com/example/android/storageprovider/MyCloudProvider.java#L296

I have an implementation of document provider, why is it that the cancellation signal is always null, when someone tries to opendocument from documentprovider ?

Thanks for your time!

getContentResolver().openInputStream(imageUri) throw FileNotFoundException

uri: content://[email protected]/union/video/item/25473

stack:

cause by:
java.io.FileNotFoundException: Unable to get item com.sec.android.gallery3d.data.UnionSCloudVideo@882a3ac
android.database.DatabaseUtils.readExceptionWithFileNotFoundExceptionFromParcel(DatabaseUtils.java:144)
android.content.ContentProviderProxy.openTypedAssetFile(ContentProviderNative.java:698)
android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1416)
android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:1253)
android.content.ContentResolver.openInputStream(ContentResolver.java:973)

device:
SM-G9350;Android 8.0.0,level 26

permission:

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />

this happed on Samsung device.

Request: for "SharingShortcuts" also show how to preset only specific apps to share with

Sometimes we would prefer to show some apps before others, and sometimes only very specific apps.

This was possible before using EXTRA_INITIAL_INTENTS , but for some reason it seems it can show now only up to 2 items and that's it. No customization potential as before.

I hope I'm wrong about this, so please share a sample of how to do it, just like before Android Q.

App Does Not Compile

Issue by commonsguy
Sunday Apr 14, 2019 at 19:41 GMT
Originally opened as googlearchive/android-SharingShortcuts#2


Steps to Reproduce:

  • Clone the repo
  • Attempt to build the app

Expected Results: for the app to build

Actual Results: the app fails with compile errors on references to Intent.EXTRA_SHORTCUT_ID, as that is new to Android Q but the Application module's compileSdkVersion is 28

Workaround: change Application/build.gradle to use compileSdkVersion 'android-Q'

java.lang.IllegalStateException: displayName must not be null

Platform:Android 9

  --------- beginning of crash
2020-08-20 18:09:48.210 28937-28937/com.android.samples.mediastore E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.android.samples.mediastore, PID: 28937
    java.lang.IllegalStateException: displayName must not be null
        at com.android.samples.mediastore.MainActivityViewModel$queryImages$2.invokeSuspend(MainActivityViewModel.kt:197)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
        at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594)
        at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60)
        at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)
2020-08-20 18:09:48.221 28937-28937/com.android.samples.mediastore I/Process: killProcess pid=28937
    java.lang.RuntimeException
        at android.os.Process.killProcess(Process.java:1005)
        at com.android.internal.os.RuntimeInit$KillApplicationHandler.uncaughtException(RuntimeInit.java:157)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1068)
        at java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:1063)
        at kotlinx.coroutines.android.AndroidExceptionPreHandler.handleException(AndroidExceptionPreHandler.kt:40)
        at kotlinx.coroutines.CoroutineExceptionHandlerImplKt.handleCoroutineExceptionImpl(CoroutineExceptionHandlerImpl.kt:30)
        at kotlinx.coroutines.CoroutineExceptionHandlerKt.handleCoroutineException(CoroutineExceptionHandler.kt:33)
        at kotlinx.coroutines.StandaloneCoroutine.handleJobException(Builders.common.kt:184)
        at kotlinx.coroutines.JobSupport.tryFinalizeFinishingState(JobSupport.kt:226)
        at kotlinx.coroutines.JobSupport.tryMakeCompletingSlowPath(JobSupport.kt:849)
        at kotlinx.coroutines.JobSupport.tryMakeCompleting(JobSupport.kt:811)
        at kotlinx.coroutines.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:787)
        at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:111)
        at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:46)
        at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:334)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:196)
        at android.app.ActivityThread.main(ActivityThread.java:7334)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

request for information regarding super user in android

I have android device which is rooted. I need to perform Runtime.getRuntime().exec("su") .and I have added READ_LOGs permission in manifest also. But even though i have root device its still gives me access denied. I have seen most of the blogs still the issue remains same. Can you please tell me Is there anything missing here

[BUG] This example project doesn't work on Android 5

I'm trying to run ActionOpenDocumentTree and ActionOpenDocument with Emulator Android 6 and 5 but my docx and pdf files not showing in the native file picker, but it will show if I have some third-party file manager installed.

With 3rd party explorer Without 3rd party explorer
image

Files copied by using Files.copy are not displayed in Gallery

I am using Files.copy API (Package: java.nio.file) for copying images to new directory. The operation is working fine and I can see files are copied properly in new directory. But those newly copied files are not visible in Gallery by default.

If if use default file manager and try to move those newly copied files again in new folder then that new folder is immediately visible in phone gallery.

Do I need any change here? or I am missing something ?

Code snippet which I am using:

for (Path srcPath : sourcePaths) {
                String fileName = srcPath.getFileName().toString();
                File targetFile = new File(SDCARD_PATH + TARGET_PATH + fileName);


                if (!fileName.equalsIgnoreCase(".nomedia") && !targetFile.exists()) {
                    Files.copy(srcPath, targetFile.toPath(), StandardCopyOption.COPY_ATTRIBUTES);
                }
            }

Use a ContentObserver in MediaStore

In the MediaStore sample we currently load images in onResume, which isn't really best practice. We should switch to creating a ContentObserver and using the callbacks from it to update the LiveData.

Question: for "SharingShortcuts", how do I set which items to show on the sharing dialog?

Previously, we could use EXTRA_INITIAL_INTENTS to choose exactly which exact intents items to show, and in which order:

https://stackoverflow.com/a/41140508/878126

How can we do the same now when choosing to share?

On Q, now when I use EXTRA_INITIAL_INTENTS, it can show only up to 2 items, and that's it. Can't show more than that, and it's terrible.

Here's what happens when I try to show 3 items, of "com.ghisler.android.TotalCommander", "com.google.android.gm","com.whatsapp" :

android-sample-file-provider.zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.