0
我通過調用系統默認動作設置從SD卡作爲牆紙圖像..如何使用系統默認操作設置壁紙
我通過調用系統默認動作設置從SD卡作爲牆紙圖像..如何使用系統默認操作設置壁紙
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();
}
}
添加下面的權限在Menifest.xml
<uses-permission android:name="android.permission.SET_WALLPAPER" />
播種編號:
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);
它直接設置壁紙..但它沒有調用默認的裁剪動作... – karthik
@karthik是它的直接設置。 –
@ CapDroid我想通過使用系統默認動作裁剪圖像,並設置壁紙.. – karthik