什麼,我試圖做的是創建一個新的文件夾,並節省相機在folder.I拍攝的圖像正在嘗試使用以下snipet實現它:使用ACTION_IMAGE_CAPTURE
public class DocsAdd extends Activity
{
private static int TAKE_PICTURE = 1;
private Uri outputFileUri;
Bitmap thumbnail;
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
File filename;
try
{
long currentTime = System.currentTimeMillis();
String fileName = "img" + currentTime+".jpg";
String path = Environment.getExternalStorageDirectory().toString();
filename = new File(path + "/AutoistDiary/"+ fileName);
FileOutputStream out = new FileOutputStream(filename);
out.flush();
out.close();
MediaStore.Images.Media.insertImage(getContentResolver(),filename.getAbsolutePath(), filename.getName(), filename.getName());
outputFileUri = Uri.fromFile(filename);
}
catch (Exception e)
{
e.printStackTrace();
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, TAKE_PICTURE);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (requestCode == TAKE_PICTURE)
{
Uri imageUri = null;
if (data!=null)
{
if (data.hasExtra("data"))
{
thumbnail = data.getParcelableExtra("data");
Intent docsShow_intent=new Intent(this,DocsShow.class);
startActivity(docsShow_intent);
}
}
else
{
}
}
}
}
但是當我運行它在Optimus1上沒有返回任何結果給我的活動,遇到了一個鏈接Camera on Android Example,其中指出我目前面臨的同樣的問題,所以可以幫助我。 ?
下面的答案是否適合您? – 2013-07-21 02:07:28
爲什麼不試一試就試試@JeremyWest大多是的,它正在工作......! – sankettt 2013-07-22 04:35:59
僅供參考,答案旁邊有一個複選標記,如果有人對你有用,你可以點擊它並接受答案。在StoreImage(this,Uri.parse(outputFileUri),puc_img)給出錯誤 – 2013-07-29 17:40:00