我是Android工作室的初學者。我創建了一個對話視圖,並有按鈕進入相機激活。我找不出一種方法來激活它。我只想在按下按鈕後立即啓動相機。這裏是我的代碼:如何在android studio中按下按鈕後啓動相機?
public class AddPictureDialog extends Dialog {
private Context context;
private Camera camera;
final Button takePhoto;
private DB myDB;
private SQLiteDatabase database;
private Person person = new Person();
public AddPictureDialog(Context context) {
super(context);
this.context = context;
setCanceledOnTouchOutside(false);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.addimage_layout);
camera = new Camera();
takePhoto = (Button) findViewById(R.id.takenewphoto);
takePhoto.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Code here
}
});
}
}
http://developer.android.com/training/camera/index.html – CommonsWare