如何将图像发送到画廊来设置壁纸? [英] how to send images to gallery for setting the wallpaper?
本文介绍了如何将图像发送到画廊来设置壁纸?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图使用集成默认库的应用程序设置为墙纸的选择,我不知道如何使用意图的图像发送到画廊。我附上FB应用如何样的样子。
字符串的root = Environment.getExternalStorageDirectory()的toString()。
新的文件(根+/+ Constants1.APPNAME).mkdirs();
文件fileForImage =新的文件(根+/\"+Constants1.APPNAME,POS +.JPG);
如果(fileForImage.exists())fileForImage.delete();
尝试{
FileOutputStream中出=新的FileOutputStream(fileForImage);
arg0.com preSS(Bitmap.Com pressFormat.PNG,100,出);
Toast.makeText(getApplicationContext(),图像保存到+ Constants1.APPNAME +文件夹,Toast.LENGTH_SHORT).show();
了out.flush();
out.close(); }赶上(例外五){
e.printStackTrace();
}
意图emailIntent =新意图(Intent.ACTION_ATTACH);
emailIntent.setType(图像/ PNG);
emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(fileForImage));
startActivityForResult(Intent.createChooser(emailIntent,POS +。JPG),0);
的问题是,图像不传递给像册..
解决方案
意图emailIntent =新意图(Intent.ACTION_ATTACH_DATA);
emailIntent.setDataAndType(Uri.fromFile(fileForImage),图像/ *);
//emailIntent.putExtra(Intent.EXTRA_STREAM,Uri.fromFile(fileForImage));
startActivity(emailIntent);
Toast.makeText(getApplicationContext(),图像保存到+ Constants1.APPNAME +文件夹,Toast.LENGTH_SHORT).show();
i was trying to integrate set as wallpaper option using default gallery app, I don't know how to send the image to gallery using intent. I am attaching fb app samples how its look like.
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);
The problem is that the image is not passing to the gallery..
解决方案
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();
这篇关于如何将图像发送到画廊来设置壁纸?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文