android / codelab-android-workmanager

Apache License 2.0
551 stars 239 forks source link

Step 9. Show final output - Button not showing #288

Open markov1100 opened 2 years ago

markov1100 commented 2 years ago

It appears as if the value that is used for the condition which sets the "SEE FILE" button visibility is null.

I've run the final code provided and the result is that this button cannot be seen. Its visibility is never set to visible because the condition is never met.

issue

HoinzeyBear commented 2 years ago

If you are targeting Q then you will be getting a permission error (I didn't use the demo code so my lines are different). This is why the URI is empty

E/MediaStore: Failed to insert image
    java.lang.SecurityException: Permission Denial: writing com.android.providers.media.MediaProvider uri content://media/external/images/media from pid=11999, uid=10086 requires android.permission.WRITE_EXTERNAL_STORAGE, or grantUriPermission()
        at android.os.Parcel.createException(Parcel.java:1950)
        at android.os.Parcel.readException(Parcel.java:1918)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183)
        at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:135)
        at android.content.ContentProviderProxy.insert(ContentProviderNative.java:476)
        at android.content.ContentResolver.insert(ContentResolver.java:1587)
        at android.provider.MediaStore$Images$Media.insertImage(MediaStore.java:982)
        at com.example.learning.workmanager.blur.workers.SaveImageToFileWorker.doWork(BlurWorkers.kt:107)
        at androidx.work.Worker$1.run(Worker.java:86)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
        at java.lang.Thread.run(Thread.java:764)
E/BlurWorkers: Writing to MediaStore failed
Kakaranara commented 2 years ago

If you are targeting Q then you will be getting a permission error (I didn't use the demo code so my lines are different). This is why the URI is empty

that's right! and the solution is only to make runtime permission about WRITE_EXTERNAL_STORAGE