There are two ways to call the mobile phone photo function in the Android system: one is to directly call the camera that comes with the mobile phone, and the other is to use your own photo app. For example, Camera360 is a powerful mobile phone photography software available in various operating systems. It can take photos of different styles and special effects, and has the cloud service and Internet sharing functions, the number of users worldwide exceeds 0.25 billion. Now, developing a mobile phone photography software is definitely not of much significance. We are no longer able to beat these predecessors. We only need to learn how to call the camera that comes with the mobile phone to take photos and get the photos, you can upload an avatar, post a text microblog, and send an image. It is very easy to complete the above functions. You do not need to add any permissions to the list file, but you only need to do so in 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 Intent (android. provider. mediaStore. ACTION_IMAGE_CAPTURE); startActivityForResult (intent, CAMREA_RESQUSET) ;}}// use the returned intent value to determine whether the photo has been taken. @ 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 );}}}