Implementation of mobile phone photo function in Android Development (source code sharing)

Source: Internet
Author: User

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


Related Article

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.