BEAR SDK release 2.0.0 brings many improvements and better practices to make your integration smoother. This section describes what steps you need to follow to update your application with the version 2.0.0 of the BEAR SDK.
Update dependency version
First update the version of the BEAR SDK dependency to 2.0.0 in your application’s build.gradle
file:
dependencies {
…
compile(‘com.bear:bearsdk:2.0.0@aar’) {
transitive = true
}
}
Application class
The config.data
asset resource file is not used anymore. You must use the secret key instead which is provided by BEAR (for development process you can use the sample application one).
Use this secret key as parameter in the BearSdk.init(String secretKey) method.
Also your android.app.Application class must not extend BearApp
as this class has been removed. You can use your own Application class in your AndroidManifest.xml. You only need to initialize the BEAR SDK in your Application class:
public class App Application {
@Override
public void onCreate() {
super.onCreate();
BearSdk.getInstance(this).init("…");
}
}
IArRouter
The IArRouter does not exist anymore, you can handle fragment navigation directly in your activity class that extends ArActivity:
- move your
showMainScreen()
content to InitStatusListener.onInitComplete - move your
openWebView(String url)
content to overridden openWebView(String url) - move your
openSuccessScanView()
content to BearCallback.onMarkerRecognized - handle
showIntro()
as you want inside or before launching your ArActivity - handle
onBackPressed()
directly in your ArActivity
See example.
ArActivity openWebView
openWebView(String url) method has been added and must be implemented to handle what to do when webview asset is clicked.
ApplicationConfig
ApplicationConfig initConfig()
method has been removed. You can set augmented reality view configuration (scan timeout and scan line color) using ArActivity methods:
See ArActivity section.
ConfigKey
has been removed. Set your secret key in your Application class as explained previously.
MarkerRecognitionCallback
MarkerRecognitionCallback
has been renamed to BearCallback. Also new callback onAssetClicked(int assetId) has been added and must be implemented.
buildMarkerFromHistory method
buildMarkerFromHistory(int markerId)
has been renamed to showArSceneWithoutTracking(int markerId)
Handler methods
ScanStatusHandler
, FlashStatusHandler
and NetworkStatusHandler
have been merged to BearHandler. Also methods are not static anymore. Screenshot process has been refactored to simple method calls from BearHandler, see example. You can retrieve the BearHandler by calling ArActivity.getHandler() method and use it to call all following methods:
- boolean isScanRunning()
- void startScan()
- void stopScan()
- boolean isFlashEnabled()
- void enableFlash()
- void disableFlash()
- void cleanView()
- void triggerFocus()
- boolean isNetworkReachable()
Network monitoring will be removed in future release
- void addScanListener(ScanStatusListener listener)
- void removeScanListener(ScanStatusListener listener)
- void addFlashListener(FlashStatusListener listener)
- void removeFlashListener(FlashStatusListener listener)
- void addNetworkListener(NetworkStatusListener listener)
Network monitoring will be removed in future release
Network monitoring will be removed in future release
- void registerBearCallback(BearCallback callback)
- void unregisterBearCallback(BearCallback callback)
- void takeScreenshot(ScreenshotCallback callback)
- void cancelScreenshot()
Firebase
Firebase is not included inside BEAR SDK anymore as it should be managed at application level. You must declare your own FirebaseInstanceIdService and call BearSdk.registerFirebaseToken(String token) method inside onTokenRefresh().