1

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!

James
  • 1,071
  • 1
  • 11
  • 16
  • 1
    possible duplicate of [android pick images from gallery](http://stackoverflow.com/questions/5309190/android-pick-images-from-gallery) – Eugen Pechanec Jan 18 '15 at 19:34
  • @Eugen Pechanec thank you. Gallery can be accessed now but there's some further issue. – James Jan 19 '15 at 02:52

0 Answers0