Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 通过intent将图像传递到默认墙纸应用程序_Android_Android Wallpaper - Fatal编程技术网

Android 通过intent将图像传递到默认墙纸应用程序

Android 通过intent将图像传递到默认墙纸应用程序,android,android-wallpaper,Android,Android Wallpaper,我们正在尝试使用我们的应用程序将下载的图像(并存储在galley中我们自己的文件夹下)设置为墙纸,并使用下面的代码工作 public void Set_Current_wallpaper() { File f = new File(mCurrentWallpaperPath); // mCurrentWallpaperPath is Our folder inside gallery Uri contentUri = Uri.fromFile(f); Intent int

我们正在尝试使用我们的应用程序将下载的图像(并存储在galley中我们自己的文件夹下)设置为墙纸,并使用下面的代码工作

public void Set_Current_wallpaper() {
    File f = new File(mCurrentWallpaperPath); // mCurrentWallpaperPath is Our folder inside gallery
    Uri contentUri = Uri.fromFile(f);
    Intent intent = new Intent(Intent.ACTION_ATTACH_DATA);
    intent.addCategory(Intent.CATEGORY_DEFAULT);
    intent.setDataAndType(contentUri, "image/*");
    intent.putExtra("mimeType", "image/*");
    startActivity(intent);
}
现在的问题是,当上面的代码运行时,下面是设置墙纸应用程序屏幕的样子,但如果我们直接从gallery打开图像并设置为墙纸,这就是墙纸设置屏幕的样子。为什么它以不同的方式开放?在此处连接屏幕实际与预期

实际结果

预期结果

您试过壁纸管理器吗

WallpaperManager wallpapermgr = WallpaperManager.getInstance(this);
wallpapermgr.setBitmap(yourbitmap);

是的,但它将直接设置壁纸,而无需任何移动或放置图像的选项。@zamrony-p-juhara有关此问题的建议或问题,您可以将其放入评论中。@michael,谢谢您,但我需要50个声誉才能对某人的答案发表评论;)@但是将问题作为答案(或糟糕的答案)发布不会为你赢得声誉。要做出一个好的答案可能需要额外的工作。到达50代表处后,您可以发表评论。@unitedartinc如果您使用墙纸管理器设置墙纸,您必须自己处理图像裁剪。我想这就是为什么你的实际结果与预期结果不同。这两个应用程序(默认壁纸选择器和图库)处理自己的壁纸任务的方式不同。