因此,在我的应用中,它正在接收来自其他应用程序的图像
Intent intent = getIntent();
String action = intent.getAction();
String type = intent.getType();
if (Intent.ACTION_SEND.equals(action) && type != null) {
handleSendImage(intent); // Handle single image being sent
public void handleSendImage(Intent a)
{
Uri pic = (Uri) a.getParcelableExtra(Intent.EXTRA_STREAM);
}
从这里开始,我希望将Uri保存为图像库中的图像。
我知道如何在库中保存文件我不知道如何以正确的格式保存Uri以保存它。我知道它包含图像,因为picView.setImageURI(pic);
会导致图片出现在我的活动中。我只是希望能够将该图像保存到图库中。有关如何做到这一点的任何想法?我认为我可以将ImageView转换为位图并从那里开始,但这似乎对我来说效率非常低,并且必须有更好的方法来实现它。因为我知道你可以从文件创建Uris但是你可以从Uri创建一个文件吗?