基本上,我想做的是允许用户自己制作folder,然后转到activity包含的button来启动camera。
从这里我希望能够启动camera并将camera图像保存到新创建的文件夹中。
我在将camera图像保存到新创建的文件夹的最后一部分时遇到麻烦。
这是我的Code:
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.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); @Override public void onClick(View v) { final String name = text.getText().toString(); final String placeName = text2.getText().toString(); String place = placeName.substring(0,3); String direct = name + place ; File folder = new File("/sdcard/CameraTest/" + direct + "/"); folder.mkdirs(); Intent myIntent = new Intent(CameraTestActivity.this, Press.class); myIntent.putExtra("key", "/sdcard/CameraTest/" + direct + "/"); startActivity(myIntent); } });
从这里我过渡到此活动:
public class Press extends Activity {
/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.afterenter); final String direct = this.getIntent().getStringExtra("key"); // TODO Auto-generated method stub Button p = (Button) findViewById(R.id.button2); p.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent camera= new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); startActivityForResult(camera, 1); } }); Button np = (Button) findViewById(R.id.button3); np.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent next = new Intent(Press.this, CameraTestActivity.class); startActivity(next); } }); } }
请告诉我如何将中的图像保存camera到新创建的文件夹中。
我希望用户能够拍摄几张照片,然后将这些几张照片保存到该特定文件夹中。
在调用相机活动之前添加此代码,
Uri uriSavedImage=Uri.fromFile(new File("/sdcard/flashCropped.png")); camera.putExtra(MediaStore.EXTRA_OUTPUT, uriSavedImage); startActivityForResult(camera, 1);