Table of contents
This document presents the basic principles and different classes of the Android version of the SDK.
For each SDK release, a package is provided as a tar-gzipped file. Uncompress to get access to the SDK library and sample code.
The SDK package contains two directory with the following content:
libs/
containing the SDK library (as a AAR file) which is needed to be embedded in
your project.
demos/
containing a sample demo application using the SDK.
To embed the SDK in your Android application using Android Studio, follow the below steps:
libs
directory in the app/ directory of your project.
vdarsdk-release.aar
residing in the libs/
directory of the SDK
into the newly created libs/
directory of your project.
build.gradle
file of your application, add the following lines:
repositories { mavenCentral() flatDir { dirs 'libs' } } dependencies { implementation name:'vdarsdk-release', ext:'aar' implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.github.mhiew:android-pdf-viewer:3.2.0-beta.1' // your own dependencies are here }
The SDK comes with a view class VDARAnnotationView
rendering the
camera view and the annotations. The best practice is to embed this view in an "Augmented Reality
Activity" in your application. When the user wants to use the augmented reality part of the application, you
can then launch this AR activity accordingly.
You AR activity would typically perform the following task when created (in the Activity onCreate(Bundle) method):
startSDK(Context, String, String)
method.isLoaded()
before calling any functions of the SDK
Controller.addNewAfterLoadingTask(Runnable)
method. All the
tasks scheduled will be run on the main UI thread.VDARSDKController.getInstance().setActivity(this);
VDARSDKController.getInstance().setEnableCodesRecognition(true);
Note that this not only provide to your activity the ability to recognize standard QR code but the
SDK understands special QR codes that can be used to trigger the download of a specific content, to
trigger a tag-based synchronization of contents or even to switch the used servers to the Vidinoti Test
Servers. See the
setEnableCodesRecognition(boolean)
method
documentation for more information.
Start the download of some contents from your V-Director account. You can start a synchronization so that all contents you have published on V-Director platform will be available on the users devices. When you delete / add new contents in your account, the corresponding contents will also be added/deleted on users devices. The best practice is to launch a synchronization every time the application is launched, even if the AR activity is not opened. This allows a seamless user interactino as the user won't need to wait for the content to be loaded when the AR activity is opened.
The following sample code shows how to make a synchronization:
//We schedule a task to be run after the manager it is loaded as it is more or less sure tha //the loading process is not yet done. VDARSDKController.getInstance().addNewAfterLoadingTask(new Runnable() { public void run() { VDARRemoteController.getInstance().syncRemoteContextsAsynchronouslyWithPriors(null, new Observer() { public void update(Observable observable, Object data) { ObserverUpdateInfo info = (ObserverUpdateInfo) data; if (info.isCompleted()) { Log.v("MyActivity", "Done syncing. Synced " + info.getFetchedContexts().size() + " contents:"); for (String mID : info.getFetchedContexts()) { Log.v("MyActivity", mID); } } } }); } });
DeviceCameraImageSender imageSender = new DeviceCameraImageSender();
VDARAnnotationView
into your activity view layout using the CustomView
element of the Android Interface builder.VDARAnnotationView
that you have embedded as soon as your activity is paused
/ resumed. Not doing so will make your application crash.
To be compatible with Android 6, you have to redirect the calls to onRequestPermissionsResult() in your activity to the SDK. Put this in your activity: