Android SDK Integration Manual
Last updated
Last updated
Blippar Android SDK should be linked as a part of an Android project in Android Studio or another Android IDE. The SDK supports Android 4.4 or later, you need to build your app with Android SDK Revision 19.0.0 (API Level 19) or later. The SDK is built with a target SDK version of 27.
The SDK contains four architectures: armeabi-v7a, arm64-v8a, x86_64 and x86.
Currently, the BlipparSDK only supports full screen portrait mode. This can be set in the activity xml or programmatically.
Gradle 3.x.x is not yet supported, please use 2.x.x.
You must obtain a license key from Blippar to use the SDK in your app. This key must be embedded into your app source code and then given to the SDK during its initialisation (this is shown in the example below.)
If you have more than one app then you will need separate keys for each app.
The Android SDK bundle is distributed as an AAR module file.
Assuming you are using Android Studio 1.3 or later please follow the following steps to import the Android SDK to your project:
Save the provided .AAR file locally.
Open the project you want to use SDK with.
Import a local .AAR file via the following menu: File>New>New Module>Import .JAR/.AAR Package
.
This should automatically add the following line to your app build.gradle
file under dependencies
section:
Where :blipparsdk
is the name you have given to the Blippar SDK module. If this line has not been added automatically, please add it manually. You may encounter an error:
If you add the following line to your AndroidManifest.xml <application>
tag:
If tools appear in red in Android Studio then may need to hover over tools and hit alt+enter to automatically import the correct namespace.
The SDK requires following basic permissions to function:
the camera,
internet,
network state.
Without these the SDK will not function.
There are a few optional permissions. The SDK will function without them, but if the blipp requires one or several optional permissions to function correctly, it may not work and even crash at runtime if permissions are not granted.
It is recommended you only acquire the permissions you know your app needs to run blipps. If you know your blipp while running in your custom app won't be saving or picking photos from the gallery/Photos then you should not acquire the permission.
When targeting Marshmallow or higher the optional permissions are requested from the SDK dynamically at runtime, if not already granted. This only happens at the point at which an operation that requires the permission is performed in the blipp. The one exception to this is the location permission, this must be explicitly acquired by the client app and is never requested by the SDK. You can overload the text used for the various permission prompts if desired.
If targetting earlier versions than Marshmallow then you'll need to request the permissions up front in your AndroidManifest.xml (see below):
The SDK has a few dependencies.
The SDK allows these libraries to be changed via your app's build.gradle.
Below is a table that outlines the various versions:
Gradle Parameter | Default (if missing from root project) |
---|---|
ext.supportLibVersion | 27.1.0 |
ext.googlePlayServicesVersion | 12.0.1 |
ext.junitVersion | 4.12 |
ext.mockitoVersion | 2.3.3 |
ext.buildToolsVersion | 27.0.3 |
ext.minSdkVersion | 19 |
ext.targetSdkVersion | 27 |
ext.compileSdkVersion | 27 |
The SDK gradle defines a proguard configuration using the 'consumerProguardFiles 'blipparsdk_proguard-project.pro'. This means there is nothing special you should need to do.
Java / Kotlin
Open (or create) your Application
class/Kotlin file.
Add the following line at the top of the file below your own import statements (Android Studio does this automatically for you)
Search for the callback onCreate()
or override it.
Add the following lines to setup and start the Android Blippar SDK:
Note: Please keep your key secure. Do not store it inside any obviously textual files inside your application bundle.
As Blippar SDK is using a camera feed to display an AR experience we assume that developer has taken care of getting the camera permission. Launching the SDK without camera permission will crash the app. Location permission is optional and is only needed if the client's custom app is going to display a location-based AR experience. See the "Permissions" chapter in this document for more detail.
The BlipparSDKFragment/BlipparView must be full screen. For more information, see this document on how to hide the status bar
If using AppCompat you will need to use windowActionBarOverlay as opposed to the android namespaced one in your activity/app's theme in xml.
If you do not make the view full screen then certain undesirable resizing of blipp content can happen on backgrounding and foregrounding of the app. We will fix this issue in a future release of the SDK.
Java
In the activity .xml
file add a fragment with the class property set to "com.blippar.ar.android.sdk.BlipparSDKFragment". Alternatively, create the fragment programmatically based on the BlipparSDKFragment
class, there is a convenience static BlipparSDKFragment.create()
function.
To control the SDK lifecycle you need to create an SDK observer and override its default callbacks. Use the onInitialiseSuccess
callback to start blipp detection:
In the activity class add an observer for the SDK:
Don't forget to remove the observer after it is not used anymore (overriding onDestroy
callback would be a good place for that):
Kotlin
In the activity .xml
file add a fragment with the class property set to "com.blippar.ar.android.sdk.BlipparSDKFragment". Alternatively, create the fragment programmatically based on the BlipparSDKFragment
class, there is a convenience static BlipparSDKFragment.create()
function.
To control the SDK lifecycle you need to create an SDK observer and override its default callbacks. Use the onInitialiseSuccess
callback to start blipp detection:
In the activity class add an observer for the SDK:
Don't forget to remove the observer after it is not used anymore (overriding onDestroy
callback would be a good place for that):
Java
To respond to the blipp lifecycle you need to implement a blipp state listener.
Create a blipp event listener object based on the BlippStateListener class. It has several callbacks that will allow you to follow the blipp lifecycle events: onBlippLoading
, onBlippError
, onBlippRunning
, onBlippWaitingForTrackingLock
, onBlippClosing
and onBlippClosed
.
You can cache the blippcontext
provided by the BlippEventListener.onBlippLoading
callback to control the Blipp lifecycle. However, the BlipparSDKFragment
already does this so beware that cache the context may cause reference problems if you don't release it correctly. The BlipparSDKFragment
there is a function to close the currently running Blipp called closeCurrentBlipp
.
Kotlin
To respond to the blipp lifecycle you need to implement a blipp state listener.
Create a Blipp event listener object based on the BlippStateListener
class. It has several callbacks that will allow you to follow the Blipp lifecycle events: onBlippLoading
, onBlippError
, onBlippRunning
, onBlippWaitingForTrackingLock
, onBlippClosing
and onBlippClosed
.
Register with the SDK
Make sure you remove the listener in your onDestroy()
You can cache the blippcontext
provided by the BlippEventListener.onBlippLoading
callback to control the blipp lifecycle. However, the BlipparSDKFragment
already does this so beware that cache the context may cause reference problems if you don't release it correctly. The BlipparSDKFragment
there is a function to close the currently running Blipp called closeCurrentBlipp
.
Add com.blippar.ar.android.DebugView
to your view/activity. Ideally, it would be full screen and on top of everything else.
The DebugView can be toggled (slid in and out) by tapping the bottom of the UI. It will slide down and reveal other options.
The debug view really is only useful when in a blipp but there are some helpful options within the 'More..' overflow
Once you have a running app you may wish to test against some real markers. See the provided Sample Markers document.
Once the SDK has been initialised call the SDK's setDebugTestBlippsEnabled
function and set this to true in order to see the sample markers.
Make sure you turn off this flag (by default it is off) before releasing your app to the public. It is also possible to increase the verbosity of the logging system within thSDK.
There are two sample apps provided, one in Java and one in Kotlin.
They are an example of the most basic integration of the SDK.
The keys have been removed from the project so you need to provide your own key. You can do this in App.java
or App.kt
.
You will also need to change the package name in the AndroidManifest.xml
to your licensed package name to validate the SDK.