gpt4 book ai didi

android - 如何将图像发送到画廊以设置壁纸?

转载 作者:行者123 更新时间:2023-11-30 03:08:41 25 4
gpt4 key购买 nike

我正在尝试使用默认图库应用程序集成设置为墙纸选项,但我不知道如何使用 Intent 将图像发送到图库。我附上了 fb 应用程序示例,它的外观如何。

wallpaper1 wallpaper2

 String root = Environment.getExternalStorageDirectory().toString();
new File(root + "/"+Constants1.APPNAME).mkdirs();


File fileForImage = new File(root + "/"+Constants1.APPNAME, pos + ".jpg");
if (fileForImage.exists()) fileForImage.delete();
try {
FileOutputStream out = new FileOutputStream(fileForImage);
arg0.compress(Bitmap.CompressFormat.PNG, 100, out);
Toast.makeText(getApplicationContext(), "Image is saved to "+Constants1.APPNAME+" folder", Toast.LENGTH_SHORT).show();
out.flush();
out.close();

} catch (Exception e) {
e.printStackTrace();
}
Intent emailIntent = new Intent(Intent.ACTION_ATTACH);
emailIntent.setType("image/png");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileForImage));
startActivityForResult(Intent.createChooser(emailIntent, pos+".jpg"),0);

问题是图像没有传递到画廊..

最佳答案

     Intent emailIntent = new Intent(Intent.ACTION_ATTACH_DATA);
emailIntent.setDataAndType(Uri.fromFile(fileForImage), "image/*");
//emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(fileForImage));
startActivity(emailIntent);
Toast.makeText(getApplicationContext(), "Image is saved to "+Constants1.APPNAME+" folder", Toast.LENGTH_SHORT).show();

关于android - 如何将图像发送到画廊以设置壁纸?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21348052/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com