Android 通用的Intent介绍( 二 )


static final int REQUEST_IMAGE_CAPTURE = 1;static final Uri locationForPhotos;public void capturePhoto(String targetFilename) {Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);intent.putExtra(MediaStore.EXTRA_OUTPUT,Uri.withAppendedPath(locationForPhotos, targetFilename));if (intent.resolveActivity(getPackageManager()) != null) {startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);}}@Overrideprotected void onActivityResult(int requestCode, int resultCode, Intent data) {if (requestCode == REQUEST_IMAGE_CAPTURE...}}