我使用的意圖來初始化以下操作 在對話框
此外,我想相機選項也該畫廊選項畫廊一起初始化相機的選擇,我想下面的代碼,但沒有奏效
Intent cameraIntent = new Intent();
cameraIntent.setType(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.setType("image/*");
cameraIntent.setAction(Intent.ACTION_GET_CONTENT);
//startActivityForResult(Intent.createChooser(intent, "Select Picture"),0);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
它顯示了庫選項,但相機.. 幫我找出這個問題....
編輯:
public boolean onCreateOptionsMenu(Menu menu) {
// TODO Auto-generated method stub
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// TODO Auto-generated method stub
switch (item.getItemId()) {
case R.id.cameraa:
// Toast.makeText(this, "Save Project!", Toast.LENGTH_LONG).show();
Intent intents = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(Environment.getExternalStorageDirectory(),
"Pic.jpg");
intents.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
startActivityForResult(intents, 1);
break;
case R.id.gallery:
// Toast.makeText(this, "Take Snapshot!", Toast.LENGTH_LONG).show();
// ////This is gallery intent
Intent intent = new Intent();
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
startActivityForResult(
Intent.createChooser(intent, "Select Picture"), 0);
break;
}
return true;
}
您的建議@Hidde,謝謝,我接受ANS時,他們對我非常有用.. – Numair