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);}}}