You can display and use the augmented reality view using the 2 following classes:
The com.bear.common.sdk.ui.activities.main.ArActivity class provides an augmented reality view so you can easily embed it in your application. Create an activity that extends ArActivity. Your activity must at least implement the following methods:
- inflateContentView(): here you must inflate your desired layout and add it as an additional content view to the activity by calling addContentView method.
- openWebView(String url): this method will be triggered when a webview asset will be clicked by user. Here you can define the behavior of your application for managing webview assets. You can either invoke the browser application with a URL intent or handle it as a webview displayed in a fragment for example.
In addition, you can specify the behavior of your augmented reality activity by overriding the following methods:
- int getScanTimeout() which will return the timeout in seconds for the scan. The default implementation will return 0 which disables the timeout.
- int getScanLineColor() which will return the color for the scan line as an integer value. Default value is white.
While augmented reality view initialization in progress, screen will be black. You can display a drawable instead just by overriding the
ar_splashscreen.xml drawable resource.
When a marker is recognized, the augmented reality view will automatically display this marker and its assets. You can remove it from the view by calling the BearHandler.cleanView() method. See BearHandler section for more information on this class.
You can find basic and advanced example in our sample application.
The com.bear.common.sdk.IBearHandler class gives you ability to handle several features of the BEAR SDK:
- register/unregister callbacks for BEAR SDK. See Callbacks section.
- add/remove listeners for scan status and flash status
- start/stop scan and check current scan status
- enable/disable flash and check current flash status
- trigger camera focus
- clean the augmented reality view from displaying marker and assets
- take a screenshot of the augmented reality view
The IBearHandler is attached to an ArActivity and can be used inside it and its fragments using ArActivity.getBearHandler method. The IBearHandler should not be called outside of these contexts.