LOD - Android SDK
V 1.6.8 (released 20/04/22)
Support
- The LANDMARKS ID SDK supports Android 4.0.3 Ice Cream Sandwich (API 15) and above.
User Permissions
This LANDMARKS ID SDK is designed for use with
ACCESS_FINE_LOCATION
permissions.No special permissions need to be added to the Manifest. However, it is highly recommended that a custom permission request dialog for location be shown to the user, although technically not required.
Setup Instructions
Installation
- Open your root
build.gradle
file and add the JitPack repository:
allprojects {
repositories {
...
maven {
url "https://jitpack.io"
credentials { username "[LANDMARKS TO PROVIDE]" }
}
}
}
- Add the line below as a dependency in your app-level
build.gradle
:
dependencies {
implementation '[ENTER DEPENDENCY REFERENCE HERE]'
}
Example Dependency Reference: "com.gitlab.landmarksid:sdk-android-lo:1.2.3"
Initialisation
Application Class
Add the following line inside the Application
class’s onCreate()
method:
LandmarksID.getInstance().initMetaData(getApplicationContext());
Starting the SDK
In your main activity's onCreate()
method, initialise and start the LANDMARKS ID SDK:
landmarksId = LandmarksID.getInstance().start(this, options);
.start()
accepts two arguments- a context, and a LandmarksID.Options
object (which is described in detail below), and returns an instance of the LANDMARKS ID SDK.
Configuration
A typical LandmarksID.Options
builder would look something like this:
LandmarksID.Options options = new LandmarksID.Options()
.setApiKey(API_KEY)
.setAppMetadata(APP_ID, APP_SECRET)
.setCustomerId("sample-id")
.setCustomData(customData);
All constants in upper case are to be obtained/clarified with LANDMARKS ID, and are not part of the SDK itself
Optional Controls
Location Permission Request [Depreciated]
.setLocationUsable(Activity)
To avoid initiating unwanted location permission prompts the LANDMARKS ID SDK will only request location permissions if the application calls .setLocationUsable(Activity)
. This would cause the SDK to request permissions using a standard dialog unless otherwise specified.
NOTE: This method is only meant to called once within the application lifecycle. All consecutive calls would be ignored, regardless of the state of the location permissions.
This method can be invoked on a LandmarksID instance from any point within the application.
The Activity passed along must implement the Android callback ActivityCompat.OnRequestPermissionsResultCallback
and provide a call to the corresponding method in the LandmarksID SDK. Example:
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
landmarksId.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
The argument this
refers to the enclosing Activity. i.e.: the one passed on
Custom Data
.setCustomData(CustomData)
User data that is collected by, or made available to, the application can be passed into the LANDMARKS ID SDK, as custom values. Use this method to pass along a set of key-value pairs constructed using the provided CustomData
class. These will be recorded by the LANDMARKS ID SDK with each location event. Multiple custom values can be passed into the method.
CustomData customData = new CustomData();
customData.addString("country", "Germany");
customData.addInt("code", 49);
customData.addFloat("score", 23.58f);
At the moment, the supported types are String
, int,
and float
.
CustomData
is an extension of HashSet
, and exhibits the same behavior with one notable difference: in case an entry with a duplicate key is added, only the one added last would be kept.
Putting It All Together
public class LocationAwareApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
LandmarksID.getInstance().initMetaData(getApplicationContext());
}
}
public class MainActivity extends AppCompatActivity implements ActivityCompat.OnRequestPermissionsResultCallback {
private static final String API_KEY = "<YOUR_API_KEY>";
private static final String APP_ID = "<YOUR_APP_ID>";
private static final String APP_SECRET = "<YOUR_APP_SECRET>";
private LandmarksID landmarksId;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
CustomData customData = new CustomData();
customData.addString("country", "Germany");
customData.addInt("code", 49);
customData.addFloat("score", 23.58f);
LandmarksID.Options options = new LandmarksID.Options()
.setApiKey(API_KEY)
.setAppMetadata(APP_ID, APP_SECRET)
.setCustomerId("sample-id")
.setCustomData(customData);
landmarksId = LandmarksID.getInstance().start(this, options);
landmarksId.setLocationUsable(this);
}
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
landmarksId.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
}
File Size
SDK File Size ~ 300 KB
Contact Details
If you have any further questions please do not hesitate to contact our friendly team at;