I'm currently setting the wallpaper using wallpaper manager passing it a bitmap this works but this image is static so it doesn't move with the screen and it doesn't give me an option to crop the image. I want to use the ACTION_SET_WALLPAPER at the moment when I call it, it works for saving the image but when it tries to set the image to crop it, it gives me a toast "failed to load image" and quits back to my application,
my attempt
Bitmap bitmap = ((BitmapDrawable) WallpaperView.getDrawable()).getBitmap();
Intent setAs = new Intent (Intent.ACTION_ATTACH_DATA);
setAs.setType("image/jpg");
ByteArrayOutputStream bytes = new
ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG,100,bytes);
File f = new File
(Environment.getExternalStorageDirectory()+ File.separator +
"/my_tmp_file.jpg");
try{
f.createNewFile();
FileOutputStream fo = new FileOutputStream(f);
fo.write(bytes.toByteArray());
}catch (IOException e){
e.printStackTrace();
}
setAs.setDataAndType
(Uri.parse(Environment.getExternalStorageDirectory()+ File.separator +
"/my_tmp_file.png"),"image/jpg");
setAs.putExtra("mimeType", "image/jpg");
startActivity(Intent.createChooser(setAs, "Set Image
As"));
still pouring over this my code saves the image and then asks what the user would like to set the image as but then crashes still with the toast cant load image, if I go to the file manager I can select the image I have just saved and set it as the wallpaper no problem is there anyone who can tell me why this doesn't work?
stacktrace...
java.lang.IllegalArgumentException: URI is not absolute: /storage/emulated/0//my_tmp_file.png
at java.net.URI.toURL(URI.java:1376)
at com.lge.gallery.data.UriImage$JobState.openOrDownloadInner(UriImage.java:147)
at com.lge.gallery.data.UriImage$JobState.openFileOrDownloadTempFile(UriImage.java:105)
at com.lge.gallery.data.UriImage$JobState.prepareInputFile(UriImage.java:198)
at com.lge.gallery.data.UriImage$BitmapJob.getBitmap(UriImage.java:256)
at com.lge.gallery.data.UriImage$BitmapJob.run(UriImage.java:249)
at com.lge.gallery.data.UriImage$BitmapJob.run(UriImage.java:240)
at com.android.gallery3d.app.CropImage$LoadBitmapDataTask.run(CropImage.java:1490)
at com.android.gallery3d.app.CropImage$LoadBitmapDataTask.run(CropImage.java:1483)
at com.lge.gallery.util.ThreadPool$Worker.run(ThreadPool.java:167)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
at
com.lge.gallery.util.PriorityThreadFactory$1.run
(PriorityThreadFactory.java:43)
07-23 00:47:26.395 26470-26470/? I/StorageStateManager﹕
rootPath=/storage/emulated/0/ available_size=5782491136 request_size=1500000
07-23 00:47:26.395 26470-26470/? I/FloatableActivity﹕ onPostResume
activity=com.android.gallery3d.app.CropImage
(com.android.gallery3d.app.CropImage@149b6d72)
07-23 00:47:26.450 26470-26470/? I/FloatableActivity﹕ on attached from
window activity=com.android.gallery3d.app.CropImage
07-23 00:47:26.530 26470-27056/? I/GalleryEGLConfigChooser﹕ Config chosen:
R8 G8 B8 A0 D0 S8 ID12 CAVEAT12344
07-23 00:47:26.540 26470-27056/? I/GLRootView﹕ onSurfaceChanged: 1440x2200,
gl10: com.google.android.gles_jni.GLImpl@18efc101
07-23 00:47:26.541 26470-27056/? I/GLRootView﹕ layout content pane 1440x2200
07-23 00:47:26.568 1050-1151/? I/SystemUI[Framework]﹕
PhoneWindowManager.updateSystemUiVisibilityLw() :visibility=0x8600,
pkg=com.android.gallery3d
07-23 00:47:26.569 1461-1461/? I/[SystemUI]NavigationThemeResource﹕ notify
navigation bar color(0xff000000)
07-23 00:47:26.570 1050-1151/? W/PhoneWindowManagerEx﹕
Call!!!getLGSystemUiVisibility. =0x0
07-23 00:47:26.570 1050-1151/? I/SystemUI[Framework]﹕ ==>disabledNaviBtn()
what=0x0, token=android.os.Binder@64e735, pkg=WindowManager.LayoutParams
07-23 00:47:26.570 1050-1151/? I/SystemUI[Framework]﹕ disableNaviBtn:
mDisabledNaviBtn=0x0, mDisableRecords.size=0
07-23 00:47:26.570 1461-1461/? I/[SystemUI]NavigationThemeResource﹕
NavigationKey Color is changed(WHITE_WITH_SHADOW -> WHITE)
BarMode=4, Theme=BLACK, LightBackground=false (NOT Transparent)
After days of searching I managed to solve this using this guys answer here