Android development of mobile phone photo function implementation (source code share)

Source: Internet
Author: User

There are two ways to call a camera in the Android system. One way to directly call your phone is to use your own photo app. For example, Camera360 is a powerful mobile phone camera software that is available on every operating system, and can take photos of different styles and special effects, as well as cloud service and Internet sharing, with more than 250 million users worldwide. Now specialized in the development of a mobile phone photography software certainly does not have much significance, has been compared to these predecessors, we just need to learn how to call the mobile phone to take the camera to complete the photo capture and take photos, to provide users with upload avatar, published text micro-blog, the ability to transfer pictures. It's easy to do this, and you don't even need to add any permissions to the manifest file, just one step.

Package Com.example.g06_camera01;import Android.os.bundle;import Android.app.activity;import Android.content.intent;import Android.graphics.bitmap;import Android.view.view;import Android.widget.Button; Import Android.widget.imageview;public class Mainactivity extends Activity {private ImageView imageview;private Button Button;private final int camrea_resquset = 1; @Overrideprotected void OnCreate (Bundle savedinstancestate) { Super.oncreate (savedinstancestate); Setcontentview (r.layout.activity_main); ImageView = (ImageView) This.findviewbyid (r.id.imageview1); button = (button) This.findviewbyid (R.id.button1); Button.setonclicklistener ( New View.onclicklistener () {@Overridepublic void OnClick (View v) {//TODO auto-generated method Stubintent Intent = new in   Tent (Android.provider.MediaStore.ACTION_IMAGE_CAPTURE); Startactivityforresult (Intent, Camrea_resquset);});} Use the callback value of intent to determine if the photo has been shot @overrideprotected void Onactivityresult (int requestcode, int resultcode, Intent data) {//TODO auto-generated Method Stubsuper.onactivityresult (Requestcode, ResultCode, data); if (Requestcode = = Camrea_resquset && ResultCode = = RESULT_OK) {Bundle bundle = Data.getextras (); Bitmap Bitmap = (Bitmap) bundle.get ("Data"); Imageview.setimagebitmap (Bitmap);}}}


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.