See: Description
| Package | Description |
|---|---|
| com.layar.sdk | |
| com.layar.sdk.data | |
| com.layar.sdk.location |
The Layar SDK offers a an Android Library that implements the core functionality of Layar. Using the Layar SDK, it is possible to start our camera view in scan mode and allow your users to scan images (pages, posters, etc.) from your layers and campaigns. It also allows you to open specific layers (primarily used for geo layers). It provides simple methods for integration in your own app.
The Layar SDK supports Android 2.3 and above. It was developed and tested using the Android Developer Tools (ADT) v23 and uses targetSdkVersion 23 (Android 6.0). In the documentation, we assume the use of Android Studio as the IDE and gradle as the build process.
NOTE: since Layar SDK version 8.4.3, we dropped support for Eclipse. Earlier versions are still available as an Android Library project. As Eclipse has officially been deprecated by Google, we recommend to switch to Android Studio. If you really need to keep working on Eclipse, there are ways to convert an .aar file to a library project you could try, but we don't provide support for this.
Applications build with the SDK have a couple of hardware/software requirements that will be automatically applied to your application:
Required hardware:
camera (back-facing)
Required permissions:
CAMERA
INTERNET
ACCESS_FINE_LOCATION
ACCESS_COURSE_LOCATION
ACCESS_COURSE_UPDATES
ACCESS_NETWORK_STATE
ACCESS_WIFI_STATE
READ_EXTERNAL_STORAGE
WRITE_EXTERNAL_STORAGE
The Layar SDK is distributed as an AAR library bundled inside the SDK distribution package, and through our private maven repository (URL available on request). You need to add a dependency to the library in one of these 2 ways.
Setup gradle dependency to local .aar file
Unzip the AAR file from the SDK distribution package. In Android studio, use "File > New > New Module...", select "Import .JAR/.AAR Package" and select the layar_sdk.aar file. Next add the following dependencies in your app's build.gradle file:
dependencies {
compile project(':layar_sdk')
compile "org.jetbrains.kotlin:kotlin-stdlib:1.0.1"
}
Setup gradle dependency to the Layar maven repository
Another way to add the Layar SDK to you project it to use our private maven repository. If you do not have the link to the maven repository please get in touch with us through this form to receive all necessary information.
As the Layar SDK is not available in the public maven repository, you first need to add our repository to your projects build.gradle file:
allprojects {
repositories {
jcenter()
maven {
url "http://link to the repository"
}
}
}
After that you can add the gradle dependency in your app's build.gradle:
dependencies {
compile 'com.layar:sdk:8.4.3'
}
To use the Layar SDK, all you need to do is interact with the LayarSDK class. This contains two simple static methods for initialization and starting the Activity.
Initialization
LayarSDK.initialize(Context context, String oauthKey, String oauthSecret);
Before using the Layar SDK, you need to initialize it by providing your application Context and your OAuth credentials. These credentials are used to authenticate your application and to filter the visual search results to include only campaigns from publisher account. This method only needs to be called once in your applications lifetime.
Starting Activity
LayarSDK.startLayarActivity(Context context);
LayarSDK.startLayarActivity(Context context, String layerName);
After initialization, you can simply start the LayarSDKActivity. This will launch the Layar camera view. When no layerName is specified, the Layar activity will launch in scan mode which allows your user to scan and interact with your campaigns. When a layerName is specified, this specific layer is loaded.
You can also customize some things in the flow of the LayarSDKActivity by providing an LayarSDKClient. This client will receive event based callbacks that can be used to control and customize the flow.
LayarSDK.startLayarActivity(Context context, LayarSDKClient sdkClient);
LayarSDK.startLayarActivity(Context context, LayarSDKClient sdkClient, String layerName);
Enabling MapView support
The Layar SDK supports a Google Maps view for the Geo layers. It uses the Google Maps v2 library included in Google Play Services. In order to enable this, you need to add the Google Play Services library project to your app and add your Google Maps API key to your AndroidManifest.xml as described in the Google documentation. The Layar SDK will automatically detect this and enable the "Switch to Map View" menu option.
https://developers.google.com/maps/documentation/android/start
http://developer.android.com/google/play-services/setup.html
Integrating the Layar SDK Fragment
As an alternative to using the LayarSDKActivity, it is also possible to integrate the LayarSDKFragment in your own Activity. This allows you to build a UI on top of the Layar AR view.
NOTE: You are not allowed to alter the size and visibility of the "Powered by Layar" logo as stated in the terms and conditions. When making bigger changes to the appearance of the view, please consult with Layar to verify whether this is acceptable.