Android takes photos and displays pictures

This example shares the specific code of Android photographing and picture display for your reference. The specific contents are as follows

1. Functional declaration

When the application needs to use cameras, NFC and other peripherals, it needs to be declared in androidmanifest.xml. In this way, when the device lacks these peripherals, the app store installer can refuse to install the device.

The declaration example code is as follows:

2. Create a file object that points to a file

The photos taken can be stored in the external storage area of the device.

Android allocates unique storage areas for different applications, and further divides the storage areas according to the type of stored data. The code example for setting the photo storage area is as follows:

3. Trigger photographing

You can use mediastore.action_ CAPTURE_ Image type intent triggers photographing. The example code is as follows:

4. Process photo results

After taking photos, you can load the pictures.

Bitmap only stores the actual pixel data, so even if the original photo has been compressed, the file will not be compressed when it is stored in the bitmap object.

Therefore, when loading a picture, you need to scale the file reasonably according to the size of the given area. Then, use bitmap to load the scaled file. The example code is as follows:

The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>