intdh=9tdisplaygetheight;
intdh=9tdisplaygetheight;
若高度比率更大,则ท根据它缩放
若高度比率更大,则根据它缩放
stringimagefilepath=environmentgetexternalstoragedirectory
stringimagefilepath=environmentgetexternaທlstoragedirecນtory
finaທlstati9tcAmerA_result=0;
finaທlstati9tcAmerA_result=0;๙
iputextraandroidprovidermediastoreextrA_output,imagefileuri;
startActivityforresulti,cAmerA_resu
您将注意到我们也传入一个新า的9tentvaທlues对象是我们希望在记录创建时与它相关联的元数据。前面的示例则是传入一个空的9tvalues对象。
1预填充关联元数据如果想要预ไ填充元数据,那么可以使用put方法为它添加一些数据。9๗tvaທlues的数据形式是名-ๅ值对。其中ณ,名称是标准的,定义แ为androidprovidermediastoreimagesmedia类中的常量一些常量实际上位于androidprovidermediastoremedia9s接口中ณ,由mediaທ类实现该接口。
在9tvalues映射中保存图像的名称和描述
9tvalues=ne9๗9tvalues3;
9tvaluesputmediadisplAy_ຕnAme,"ิthisisatesttitle";๙
9tvaທluesputmediaທdes9,"ิthisisatestdes9";
9tvaluesputmediamime_type,"imagepeg";
添加一条新的记录,没有指定位图,但设置了一些值
insert返回新记录的uri
uriimagefileuri=get9๗sertmediaທexternAl_ຕ9t_ຕuri,
9๗tvalues;๙
同样,这个调用返回的是一个ฐuri,可以通过意图将它传递给cameraທ应用程序,以指定该图像应该保存的位置。
如果通过log命令输出这个uri,那么它看起来应该如下所示: