I'm trying to implement a function to pick a photo from android built-in gallery (not from SD card) or taking a photo using camera. But "No Activity found to handle Intent act=android.intent.action.PICK" error was returned. My code is as follows:
private void ShowPickDialog() {
new AlertDialog.Builder(this)
.setTitle("Add Photo")
.setNegativeButton("Select from Photos", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
Intent intent = new Intent(Intent.ACTION_PICK, null);
intent.setDataAndType(
MediaStore.Images.Media.INTERNAL_CONTENT_URI,
"image/*");
startActivityForResult(intent, 1);
}
})
.setPositiveButton("Take a Pic", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
dialog.dismiss();
Intent intent = new Intent(
MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri
.fromFile(new File(Environment.DIRECTORY_PICTURES,
"image.jpg")));
startActivityForResult(intent, 2);
}
}).show();
}
Can someone plz tell me what the problem is? Also which directory should be used at this line "intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri .fromFile(new File(Environment.DIRECTORY_PICTURES, "image.jpg")));
Thanks in advance!