Skip to content

Advanced

This section will provide more advanced features available in the BEAR SDK. Sample code is also available in our sample application.

Show Marker Without Scanning

The ArActivity also provides a method to display a marker without scanning it: showArSceneWithoutTracking(int markerId). Obviously you need the marker id to call this method; it can retrieved from BearCallback.onMarkerRecognized when user successfully scanned a marker.

The behavior is the same as when a marker is recognized from scan:

See example.

Firebase Integration

BEAR frontend provides feature to manage application notification. This section explains how to enable this feature in BEAR SDK by linking it to Firebase.

The Firebase integration is handled application side and not inside BEAR SDK. Don't hesitate to check Firebase instruction for adding Firebase to your application and setup your Firebase cloud messaging client.

For the notifications to work with BEAR SDK, you must provide BEAR with your Firebase legacy server key.

Finally you need to call BearSdk.registerFirebaseToken(String token) with the Firebase token. The Firebase token can be retrieved by overriding the onNewToken(java.lang.String) method of FirebaseMessagingService class:

public class FcmService extends FirebaseMessagingService {

    @Override
    public void onNewToken(String token) {
        super.onNewToken(token);
        if (token != null) {
            BearSdk.getInstance(this).registerFirebaseToken(token);
        }
    }

}

This way the Firebase token will be linked to the device id assigned at BEAR backend. You can retrieve this device id in your application by calling BearSdk.getDeviceId().

AR View Initialization Callback

As explained in the ArActivity section, augmented reality view takes some time to initialize.

You can be notified of the augmented reality view initialization complete by calling ArActivity.addArViewInitListener(InitStatusListener listener). The onInitComplete() callback will be called when initialization finished.

Note: all InitStatusListener listeners are automatically removed either when onInitComplete() is called or when augmented reality view is destroyed.

You can also check if augmented reality view is initialized at any time by calling ArActivity.isArViewInitialized().

Pause or Resume AR View

The augmented reality view is obviously the main consumption of the BEAR SDK. Therefore methods are provided to pause and resume the augmented reality so you can avoid battery drain when view is not in use:

Both methods are already handled in ArActivity lifecycle so you don't need to call them from another activity but you can call them from a fragment if needed.

See example for pausing and resuming.