4

我正在尝试制作墙纸应用程序。我可以使用壁纸管理器设置壁纸。但是我想要的是当我单击一个按钮时,应该打开一个新的意图,这应该是设置设备壁纸的默认方式。(当我们尝试将图像表单库设置为墙纸时得到的屏幕,我们可以在其中选择图像区域等)。我已经护目镜,但找不到任何解决方案。

4

3 回答 3

1

这是一个更好的解决方案,您不必指定目标应用程序;

Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER);
startActivity(Intent.createChooser(intent, "Select Wallpaper"));
于 2014-11-30T10:31:10.627 回答
0

使用"android.intent.action.SET_WALLPAPER"+ 设置墙纸应用程序的组件/类,以便您的应用程序处理 Intent。

例如,对于 AOSP 内置壁纸应用程序,如下所示:

Intent intent = new Intent("android.intent.action.SET_WALLPAPER");
// Change the following line with that of your own app
intent.setClassName("com.android.launcher", "com.android.launcher2.WallpaperChooser");
try {
    startActivity(intent);
} catch (ActivityNotFoundException e) {
    Log.wtf(TAG, "No activity found to handle " + + intent.toString());
}
于 2013-09-10T06:32:36.353 回答
0

我知道它迟到了,但有人想要,它对我有用。

final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
    try {
        wallpaperManager.setBitmap(yourImageView.getDrawingCache());
        finish();
    } catch (IOException e) {
        e.printStackTrace();
    }
于 2016-01-20T16:31:57.157 回答