简体   繁体   中英

What's wrong with this Intent?

What I am trying to do is, when the user chooses this option, my Android app runs an intent. The intent calls for the camera of the Android device, and the camera takes a picture, and then saves the file into the directory named posense.

path = Environment.getExternalStorageDirectory().getName() + File.separatorChar + "posense";
Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
File photo = new File(path);
Intent newintent = intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
imageuri = Uri.fromFile(photo);
startActivityForResult(newintent, 1);

Make sure that you have correct permissions in your manifest. They would be:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM