我在android中使用相机应用程序。在我的应用程序中,单击的图像将保存到SD卡,如下所示。
Camera.PictureCallback jpegCallback = new PictureCallback() {
public void onPictureTaken(byte[] data, Camera camera) {
FileOutputStream outStream = null;
try
{
outStream = new FileOutputStream(String.format("/sdcard/%d.jpg", System.currentTimeMillis()));
outStream.write(data);
outStream.close();
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
Log.d(TAG, "on pictureTaken" + data.length);
}
catch (FileNotFoundException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{}
Log.d(TAG, "on pictureTaken-jpeg");
try
{
Thread.sleep(2000);
}
catch (InterruptedException e)
{
e.printStackTrace();
}
startActivity(new Intent(FbCamera.this,view.class));
}
};
我想在另一项活动中将此图片检索到imageview。我的第二项活动如下所示。
public class view extends Activity
{
private ImageView imgView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
imgView = (ImageView)findViewById(R.id.photoResultView);
//imgView.setImageResource("");
}
}
我想显示从SDCard保存到imageview的最后一张图像。如果有人知道,请帮帮我......
答案 0 :(得分:0)
使用内容提供商(MediaStore内容提供商)授予对SD卡图像的访问权限。尝试它会帮助你。