0

I check if the user has a light/dark/warm/cold dominant wallpaper colour. And use this to give the user a nice personalized experience.

However I'm converting my app to a instant app and i cannot retrieve the wallpaper anymore (due to missing read_external_data I guess?)

Any idea if there is a way to retrieve the dominant background colour? Or another way to check what the colour preference is of the user? (Is it possible to get the colour of the status bar in the home screen or something?)

  • Do you have to use READ_EXTERNAL_STORAGE to get the wallpaper? I saw https://stackoverflow.com/questions/9939329/get-current-wallpaper, but my initial testing showed that it was restricted on O+. What other methods have you tried? And the behavior could be different on pre-O vs O+; if it is, you can report it to Google and see if it's intended or not @ https://issuetracker.google.com/issues/new?component=316045&template=1018787 – TWL Nov 13 '18 at 17:54
  • You can try checking out this [SO question](https://stackoverflow.com/questions/33623095/get-color-from-wallpaper-android). The thread has different other SO questions linked. You might be able to find one that fits your needs. – droidBomb Nov 14 '18 at 15:43
  • Both sugestions are a good way to get the dominant colour. I tested the instant app onto a android 8.0 version, and I got a permission error. I might get a different result on a 8.1 according to https://stackoverflow.com/q/47995463/8462016 . – Teun Gelder Nov 14 '18 at 18:14

1 Answers1

0

You can't retrieve the wallpaper because the "READ_EXTERNAL_STORAGE" permission is not available for instant apps.

In order for your app bundle to be instant-compatible, it can only use permissions from the following list:

  • ACCESS_COARSE_LOCATION

  • ACCESS_FINE_LOCATION

  • ACCESS_NETWORK_STATE

  • BILLING – Deprecated as of Play Billing Library 1.0.

  • CAMERA

  • INSTANT_APP_FOREGROUND_SERVICE – Only in Android 8.0 (API level 26) and higher.

  • INTERNET

  • READ_PHONE_NUMBERS – Only in Android 8.0 (API level 26) and higher.

  • RECORD_AUDIO

  • VIBRATE

https://developer.android.com/topic/google-play-instant/getting-started/instant-enabled-app-bundle#check-permissions

Source: Google's FAQ for Instant Apps (see more in https://developer.android.com/topic/google-play-instant/faqs)

@gbaccetta from this awnser: https://stackoverflow.com/a/44803286/10697279

@adamk from this awnser: https://stackoverflow.com/a/44360685/10697279

Community
  • 1
  • 1
henrique
  • 28
  • 3