Set Image as wallpaper using Intent

岁酱吖の 提交于 2019-12-06 10:25:14

I did discover a workaround:

    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(uri, "image/jpeg");
    intent.putExtra("mimeType", "image/jpeg");
    this.startActivity(Intent.createChooser(intent, "Set as:"));

or try to use

WallpaperManager


wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();

mImageView.setImageURI(imagepath);

If you have image bitmap then use this

wallpaperManager.setBitmap(useThisBitmap);

In your manifest file:

<uses-permission android:name="android.permission.SET_WALLPAPER"></uses-permission>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!