> For the complete documentation index, see [llms.txt](https://legacy-docs.usesmileid.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://legacy-docs.usesmileid.com/integration-options/mobile/android/smile-id-sdk/physical-id-card-capture.md).

# Physical ID Card Capture

The physical ID Capture introduces a way to capture photos of physical ID documents

## Steps to implementation

### Step 1

In your layout file add the SmartCardView. We advise on giving the view as much real estate as possible so match parent on both height and width is advisable

```
<com.smileidentity.libsmileid.core.idcapture.SmartCardView
        android:id="@+id/id_capture"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        <!--optional fields for customisation-->
        xmlns:app="http://schemas.android.com/apk/res-auto"
        app:faceDetectedMessage="Custom face detected message"
        app:blurryMessage="Custom message for when capture is blurry"
        app:insufficientLightMessage="Custom message for when there is insufficient light"
        app:fitIdMessage="Custom message informing the user to fit the id on the rectangle and tap for focus"
        app:flashMissingErrorMessage="Custom flash missing error message"
        app:loadingMessage="Custom message for when ID capture is loading"
        app:detectingFaceMessage="Custom message for when ID capture face detection is in progress"
        app:noFaceDetectedMessage="Custom no face detected message"
        app:capturedBlurryMessage="Custom blurriness detected in captured image"
        app:capturedDarkMessage="Custom darkness detected in captured image"
        >
 </com.smileidentity.libsmileid.core.idcapture.SmartCardView>
```

### Step 2

Initialize the view in your view controller as normal and set the listener so that the SDK can pass back information on the capture

```
SmartCardView smartCardView = findViewById(R.id.id_capture);
smartCardView.setListener(this);
```

### Step 3

Set your desired id type, this is an instance of IDType enum with options

* Idcard => Aspect ratio 1.4 or normal credit card sized IDs
* Passport => Aspect ratio 1.6 or normal passbort booklet sized IDs
* Other => will default to 1.4 aspect ratio

```
smartCardView.setIdType(<IdType>);
```

### Step 4

Start Capture, typically this should be called in your onResume so that the view maintains state with the implementing Activity/Fragment

```
@Override
protected void onResume() {
    super.onResume();
    try {
        mSmartCardView.startCapture(mCurrentTag);
    } catch (SIDException e) {
        e.printStackTrace();
    }
}
```

The start capture method will display the view which should look like below

![](/files/-Mb0MKMqONlz0vvlkHPD)

The method has a couple of possible errors that should be catered for this is important to make sure users get the best user experience and for handling possible failures gracefully.

* ```
  //When camera initialisation fails
  SIDError.COULD_NOT_INITIALIZE_CAMERA

  //when no listener is set
  SIDError.MISSING_LISTENER

  //When an empty or invalid tag is set
  SIDError.INVALID_TAG_FORMAT

  //If your app does not have camera permissions
  SIDError.PERMISSION_ERROR

  //If the camera fails to process the captured image
  SIDError.ID_CARD_PICTURE_CALLBACK_FAILED
  ```

### Step 5

Implement pausing on the capture to handle view lifecycles

```
@Override
protected void onPause() {
    super.onPause();
    mSmartCardView.pauseCapture();
}
```

### Step 6

Error handling and callbacks from the ID Capture

�

```
 @Override
public void onSmartCardViewError(Exception error) {
    //todo:handle this
}

@Override
public void onSmartCardViewComplete(Bitmap idCardBitmap, boolean faceFound) {
    //idCardBitmap the captured id card image
    //faceFound true if a face was found  on the ID
}

@Override
public void onSmartCardViewClosed() {
  //User pressed X and the ID Card has been closed
}
```

### ID Capture Custom Messaging

To enable customization and internationalization from version 7.1.0 the ID Capture allows messaging customization through out the whole capture process as demonstrated in step 1


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://legacy-docs.usesmileid.com/integration-options/mobile/android/smile-id-sdk/physical-id-card-capture.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
