Development

Creating an Android Project

Create an Android project from Android Studio by the following steps:

  • Select ‘New Project’ from the ‘File’ menu.
  • Fill in the required fields in the ‘New Project’ window.
  • Choose the ‘Phone and Tablet’ platform from the ‘Target Android Devices’ window.
  • Select ‘API 21: Android 5.0 (Lollipop)’ for ‘Minimum SDK’.
  • Add an Activity to the project and complete creating the basics of the project.

 

For general information on how to create a project with Android Studio, please refer to the following Android Developer Site: Create a Project with Android Studio >.

 

Modifying the Androidmanifest.xml

Mandatory Declaration

 

Dual Camera applications need the following permission to use device camera:

CAMERA >

<uses-permission android:name="android.permission.CAMERA" />

 

If the application uses the main camera (back-facing), declare the following hardware feature:

android.hardware.camera >

<uses-feature android:name="android.hardware.camera" />

Optional Declaration

 

If the application saves image or video files, WRITE_EXTERNAL_STORAGE > permission is required.

<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

 

If the application uses autofocus feature, declare the following hardware feature:

android.hardware.camera.autofocus >

<uses-feature android:name="android.hardware.camera.autofocus" />

 

If the application records audio, RECORD_AUDIO > permission is required.

 

Accessing Cameras

Each hardware camera of an Android device can be accessed by their unique identifier, the camera ID. By convention, the main camera (back-facing) is given camera ID: 0, the selfie camera (front-facing) ID: 1, the third camera (dual camera, either front or back facing depending on the model) ID: 2, and so on. See below tables for camera ID mappings of LG smartphones with dual camera feature.

 

Camera ID Mapping for LG V10

Camera ID

Hardware Camera

Resolution

View Angle

0

Main (back-facing)

16MP

80°

1

Dual camera (front-facing)

5MP

120°

2

Selfie camera (front-facing)

5MP

80°

 

Camera ID Mapping for LG G5

Camera ID

Hardware Camera

Resolution

View Angle

0

Main camera (back-facing)

16MP

78°

1

Selfie camera (front-facing)

8MP

78°

2

Dual camera (back-facing)

8MP

135°

 

Camera ID Mapping for LG G6

Camera ID

Hardware Camera

Resolution

View Angle

0

Main camera (back-facing)

13MP

71°

1

Selfie camera (front-facing)

5MP

100°

2

Dual camera (back-facing)

13MP

125°

APIs of Android Framework

 

The Android framework provides packages that include support for camera interface and camera features.

• Camera API: The Camera > class of the android.hardware > package (deprecated in API level 21)

• Camera2 API: The android.hardware.camera2 > package (added in API level 21)

 

You can use either Camera API or Camera2 API to access and manage camera devices in your application.

 

The Sample Application provides an example of how to access camera devices and implement camera features such as displaying preview stream.

Navigation