public class CaptureView
Displays camera preview and provides methods for tuning the user interface appearance and the capturing.
Receive the CaptureView class object from your layout inside the onCreate Activity or onViewCreated Fragment.
Override the onResume and onPause methods, embedding the UI components methods.
add startCamera
method to the onResume method;
add stopCamera
method to the onPause method.
Permissions for the camera used by the app will be requested automatically when calling startCamera
method. If
additional custom permissions are to be received, request for them before calling this method
or use interface CaptureView.ExtendedSettings
.
interface CaptureView.CameraSettings
, interface CaptureView.UISettings
, interface CaptureView.ExtendedSettings
set values will be discarded with the CaptureView object
recreation.
If you use class CaptureView
in Android Fragment you should close this Fragment with back stack name
because capture scenario may show Fragment also. Check sample below:
String BACK_STACK_NAME = "any name";
// Open
getSupportFragment()
.beginTransaction()
.replace( R.id.container, new YourFragment() )
.addToBackStack( BACK_STACK_NAME )
.commit()
// Close
getSupportFragment()
.popBackStack(BACK_STACK_NAME, FragmentManager.POP_BACK_STACK_INCLUSIVE);
If you want to localize your app, you can override the string resources of the user interface.
class CaptureView
camera_need_permission_tip_title
camera_need_permission_tip_message
camera_dialog_permission_rationale_positive_button
camera_dialog_permission_rationale_negative_button
camera_dialog_permission_rationale_title
camera_dialog_permission_rationale_message
camera_dialog_permission_settings_positive_button
camera_dialog_permission_settings_negative_button
camera_dialog_permission_settings_title
camera_dialog_permission_settings_message
class ImageCaptureScenario
ics_looking_for_document_tip
ics_move_closer_tip
ics_dont_move_tip
class MultiPageImageCaptureScenario
mpics_crop_screen_title
mpics_crop_auto_crop_button
mpics_crop_cancel_button
mpics_crop_accept_button
mpics_camera_number_of_captured_pages_fixed_count (string reference with two int formatArgs)
mpics_camera_number_of_captured_pages (plurals reference with one int formatArgs)
mpics_editor_add_page_button
mpics_editor_next_document_button
mpics_editor_done_button
mpics_editor_current_document_index (string reference with two int formatArgs)
mpics_editor_delete_all_warning_title
mpics_editor_delete_all_warning_message
mpics_editor_delete_all_warning_negative_button
mpics_editor_delete_all_warning_positive_button
mpics_editor_delete_page_warning_title
mpics_editor_delete_page_warning_message
mpics_editor_delete_page_warning_negative_button
mpics_editor_delete_page_warning_positive_button
mpics_editor_error_title
mpics_editor_error_button
mpics_editor_add_more_pages
mpics_editor_retake
mpics_editor_delete_page
mpics_editor_delete_all
mpics_editor_page_deleted
mpics_preview_title
startCamera
,
stopCamera
,
interface CaptureScenario
,
setCaptureScenario
,
startCamera
,
interface CaptureView.ExtendedSettings
,
interface CaptureView.CameraSettings
,
interface CaptureView.UISettings
,
interface CaptureView.ExtendedSettings
,
class CaptureView
,
class CaptureView
,
class ImageCaptureScenario
,
class MultiPageImageCaptureScenario
public CaptureView(@NotNull android.content.Context context)
public CaptureView(@NotNull android.content.Context context, @Nullable android.util.AttributeSet attrs)
public CaptureView(@NotNull android.content.Context context, @Nullable android.util.AttributeSet attrs, int defStyleAttr)
public CaptureView(@NotNull android.content.Context context, @Nullable android.util.AttributeSet attrs, int defStyleAttr, int defStyleRes)
@MainThread public void startCamera()
Starts the camera. It is recommended to call the method inside onResume or onStart methods of the Activity/Fragment lifecycle.
Permissions for the camera use by the app will be requested automatically when calling this method. If additional custom permissions are to be received, request for them before calling this method. Only the first call of the method is taken into account. All further repetitions will be ignored.
Important: Call the stopCamera
method in pair to the startCamera to provide access to the camera for other
applications.
stopCamera
@MainThread public void setCaptureScenario(@Nullable CaptureScenario scenario)
Sets the capture scenario.
scenario
- Capture scenario, represented by a interface CaptureScenario
object.@MainThread public void stopCamera()
Stops the camera. It is recommended to call the method inside onPause or onStop methods of the Activity/Fragment lifecycle.
Only the first call of the method is taken into account. All further repetitions will be ignored.
Important: Call the stopCamera method in pair to the startCamera to provide access to the camera for other applications.
@MainThread @NotNull public com.abbyy.mobile.uicomponents.CaptureView.CameraSettings getCameraSettings()
Returns the object that defines the settings of the camera.
interface CaptureView.CameraSettings
object.@MainThread @NotNull public com.abbyy.mobile.uicomponents.CaptureView.UISettings getUISettings()
Returns the object that defines the settings of the user interface.
@MainThread @NotNull public com.abbyy.mobile.uicomponents.CaptureView.ExtendedSettings getExtendedSettings()
Returns the object with extended settings for non-common scenarios, i.e. setting extra permissions.
interface CaptureView.ExtendedSettings
object.@MainThread public void showInfoTip(@NotNull java.lang.String tip, long duration)
Displays the specified string tip during a time period.
tip
- The text of a tip.duration
- How long the tip will be shown (in milliseconds).