I use the code below to retrieve the android lock screen wallpaper on an android 8.1 phone:
WallpaperManager manager = WallpaperManager.getInstance(getActivity());
ParcelFileDescriptor pfd = manager.getWallpaperFile(WallpaperManager.FLAG_LOCK);
if (pfd == null) // pfd is always null for FLAG_LOCK, why?
return;
Bitmap lockScreenWallpaper = BitmapFactory.decodeFileDescriptor(pfd.getFileDescriptor());
// ...
I have granted the READ_EXTERNAL_STORAGE permission and set a lock screen wallpaper beforehand.
I run the demo on a real phone, and found the pfd is always null for FLAG_LOCK, so I cannot get the lock screen wallpaper. Please help fix the problem, thanks.
from How to get android lock screen wallpaper?
No comments:
Post a Comment