public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
/**
* 拍照
* @param v
*/
public void takephoto(View v){
Intent intent = new Intent();
//拍照
intent.setAction(MediaStore.ACTION_VIDEO_CAPTURE );
File file = new File(Environment.getExternalStorageDirectory().getPath(),"paizhao.3gp");
//使用到了sd卡所以还需要在清单文件中增加sd卡读写权限
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
// 开启意图
startActivityForResult(intent, 1);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Toast.makeText(getApplicationContext(), "保存成功", 1).show();
super.onActivityResult(requestCode, resultCode, data);
}
}