I have to set the image from sdcard as wallpaper by calling the default system action..
Asked
Active
Viewed 1,677 times
1 Answers
0
File file = new File(Environment.getExternalStorageDirectory(), "your_image.jpg");
String path = file.getAbsolutePath();
File imageFile = new File(path);
if(imageFile.exists()) {
Bitmap bitmap = BitmapFactory.decodeFile(path);
WallpaperManager mWallpaperManager = WallpaperManager.getInstance(this);
try {
mWallpaperManager.setBitmap(bitmap);
} catch (IOException e) {
e.printStackTrace();
}
}
Add below permission in Menifest.xml
<uses-permission android:name="android.permission.SET_WALLPAPER" />
Code for launching cropping activity:
Intent intent = new Intent("com.android.camera.action.CROP", myIntent.getData());
if (myIntent.getStringExtra("mimeType") != null) {
intent.setDataAndType(myIntent.getData(), myIntent.getStringExtra("mimeType"));
}
intent.putExtra("crop", "true");
intent.putExtra("aspectX", 1);
intent.putExtra("aspectY", 1);
intent.putExtra("outputX", 96);
intent.putExtra("outputY", 96);
intent.putExtra("return-data", true);
startActivityForResult(intent, REQUEST_CROP_PHOTO);

Niranj Patel
- 32,980
- 10
- 97
- 133
-
@karthik yes its directly set. – Niranj Patel Aug 19 '13 at 07:22
-
@ CapDroid i want crop the image by using system default action and set wallpaper.. – karthik Aug 19 '13 at 07:25