0
먼저 사용자가 폴더를 만들고 이름을 지정할 수있는 주요 항목을 만들었습니다. 버튼을 누르면 그 다음 카메라로 이동합니다. 폴더가 생성되었지만 이미지가 경로에 저장 될 수 없습니다. 나는 완전히 혼란, 그리고 난 내 영어에 대해 사과이미지를 보내고 폴더에 저장하는 방법 user-android from
final String direct = this.getIntent().getStringExtra("key");
public static final int MEDIA_TYPE_IMAGE = 1;
/** Create a file Uri for saving an image or video */
Uri uriSavedImage=Uri.fromFile(new File(direct + "photo.jpg"));
final Uri getOutputMediaFileUri(int type){
return Uri.fromFile(getOutputMediaFile(type));
}
/** Create a File for saving an image or video */
final File getOutputMediaFile(int type){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
File mediaStorageDir = new File(Environment.getExternalStoragePublicDirectory(
Environment.DIRECTORY_PICTURES), "direct");
// This location works best if you want the created images to be shared
// between applications and persist after your app has been uninstalled.
// Create the storage directory if it does not exist
if (! mediaStorageDir.exists()){
if (! mediaStorageDir.mkdirs()){
Log.d("MyCameraApp", "failed to create directory");
return null;
}
}
// Create a media file name
String timeStamp = new SimpleDateFormat("yyyyMMdd_HHmmss").format(new Date());
File mediaFile;
if (type == MEDIA_TYPE_IMAGE){
mediaFile = new File(mediaStorageDir.getPath() + File.separator +
"IMG_"+ timeStamp + ".jpg");
} else {
return null;
}
return mediaFile;
}
}
홈페이지는이
공용 클래스 MainActivity는 {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button b = (Button) findViewById(R.id.button1);
b.setOnClickListener(new OnClickListener() {
EditText text = (EditText)findViewById(R.id.editText1);
EditText text2 = (EditText)findViewById(R.id.editText2);
EditText text3 = (EditText)findViewById(R.id.editText3);
@Override
public void onClick(View v) {
final String name = text.getText().toString();
final String placeName = text2.getText().toString();
final String dettaglio =text3.getText().toString();
String place = placeName.substring(0,3);
String direct = name + place + dettaglio ;
File folder = new File("/sdcard/CameraTest/" + direct + "/");
folder.mkdirs();
Intent myIntent = new Intent(MainActivity.this, CameraView.class);
myIntent.putExtra("key", "/sdcard/CameraTest/" + direct + "/");
startActivity(myIntent);
}
});
}
}