Android calls the System camera three steps, Android calls three steps

Source: Internet
Author: User

Android calls the System camera three steps, Android calls three steps

Step 1:

<Uses-permissionandroid: name = "android. permission. WRITE_EXTERNAL_STORAGE"/>

<Uses-permissionandroid: name = "android. permission. MOUNT_UNMOUNT_FILESYSTEMS"/>


Step 2:


Intent intent = new Intent (MediaStore. ACTION_IMAGE_CAPTURE );

 

StartActivityForResult (intent, 1 );


Step 3:

Protected void onActivityResult (int requestCode, int resultCode, Intent data ){
// TODO Auto-generated method stub
Super. onActivityResult (requestCode, resultCode, data );
If (resultCode = NewsActivity. RESULT_ OK ){
String sdStatus = Environment. getExternalStorageState ();
If (! SdStatus. equals (Environment. MEDIA_MOUNTED) {// check whether sd is available
Log. I ("TestFile ",
"SD card is not avaiable/writeable right now .");
Return;
}
String name = new DateFormat (). format ("yyyyMMdd_hhmmss", Calendar. getInstance (Locale. CHINA) + ". jpg ";
Toast. makeText (this, name, Toast. LENGTH_LONG). show ();
Bundle bundle = data. getExtras ();
Bitmap bitmap = (Bitmap) bundle. get ("data"); // obtain the data returned by the camera and convert it to the Bitmap image format.

FileOutputStream B = null;
//??????????????????????????????? Why can't I save it directly in the system album ????????????
File file = new File ("/sdcard/myImage /");
File. mkdirs (); // create a folder
String fileName = "/sdcard/myImage/" + name;

Try {
B = new FileOutputStream (fileName );
Bitmap. compress (Bitmap. CompressFormat. JPEG, 100, B); // write data to a file
} Catch (FileNotFoundException e ){
E. printStackTrace ();
} Finally {
Try {
B. flush ();
B. close ();
} Catch (IOException e ){
E. printStackTrace ();
}
}
ImageView iv = (ImageView) findViewById (R. id. news_ImageView_image );
Iv. setImageBitmap (bitmap );
}
}



What kind of learning English software is available for Android?

Other learning software can also be downloaded from the android network as Kingsoft's word master or has three-way synchronization: client, Web, and mobile phone (including Android). Learn English Lenovo memory anytime, anywhere:

How can I combine multiple videos into one video captured by a camera?

I don't know what formats the landlord uses a digital camera and video. Three-step policy is recommended: 1. Entry-level entry-movie maker. Generally, a video editing software is provided in windows, which is simple and easy to use. 2. Improvement and Development-sound and shadow (if you remember correctly, there should be an image 11 now ). There are more special effects than movie maker and more functions. 3. Professional entry-Premiere Pro 2.0. It should be regarded as high-end, more professional and more complex than the above two. There are a lot of places for research, and it is really interesting to play. If you are a video cutting and editing enthusiast, we suggest following the three-step policy above"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.