LO - Android SDK
v 2.0.0 (released 03-04-2026)
Support
- The Landmarks ID SDK supports Android 8.0 Oreo (API 26) and above.
User Permissions
This Landmarks ID SDK requires
ACCESS_FINE_LOCATIONandACCESS_COARSE_LOCATIONpermissions.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.
The SDK does not request permissions itself. The host application is responsible for requesting location permissions and forwarding the results to the SDK.
The SDK declares
READ_BASIC_PHONE_STATE(a normal, auto-granted permission) to detect cellular network generation (2G/3G/4G/5G) on Android 13+ without any user prompt. On Android 11–12, cellular connections are reported asUNKNOWNunless the host app holdsREAD_PHONE_STATE. WiFi detection works without any additional permissions.
Setup Instructions
Installation
- Add the credentials provided by LANDMARKSID to
~/.gradle/gradle.properties:
gpr.key=YOUR_ACCESS_TOKEN
The access token will be provided by LANDMARKSID.
- Open your root
build.gradlefile and add the GitHub Packages repository:
allprojects {
repositories {
...
maven {
name = "GitHubPackages"
url = uri("https://maven.pkg.github.com/LANDMARKSID/sdk-android-lo")
credentials {
username = "LANDMARKS-ID"
password = project.findProperty("gpr.key")
}
}
}
}
- Add the dependency in your app-level
build.gradle:
dependencies {
implementation 'com.landmarksid:landmarks-android-sdk-lo:2.0.0'
}
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 an Options object (described in detail below) — and returns an instance of the Landmarks ID SDK.
Configuration
A typical Options builder would look something like this:
Options options = new 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
Permission Handling (Mandatory)
The host app must request location permissions and forward the results to the SDK. The SDK automatically detects when location permissions are granted and starts location services. No additional calls are needed — just forward the result.
The SDK processes any permission result that includes ACCESS_COARSE_LOCATION or ACCESS_FINE_LOCATION, regardless of the request code used by the application.
Option A: AndroidX Activity Result API (Recommended)
private final ActivityResultLauncher<String[]> locationPermissionLauncher =
registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), results -> {
landmarksId.onRequestPermissionsResult(this, results);
});
// To request permissions:
locationPermissionLauncher.launch(new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
});
Option B: Legacy onRequestPermissionsResult
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
landmarksId.onRequestPermissionsResult(this, requestCode, permissions, grantResults);
}
Additional Controls
Custom Data (Optional)
.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 {
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;
private final ActivityResultLauncher<String[]> locationPermissionLauncher =
registerForActivityResult(new ActivityResultContracts.RequestMultiplePermissions(), results -> {
landmarksId.onRequestPermissionsResult(this, results);
});
@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);
Options options = new Options()
.setApiKey(API_KEY)
.setAppMetadata(APP_ID, APP_SECRET)
.setCustomerId("sample-id")
.setCustomData(customData);
landmarksId = LandmarksID.getInstance().start(this, options);
// Request location permissions
locationPermissionLauncher.launch(new String[] {
Manifest.permission.ACCESS_COARSE_LOCATION,
Manifest.permission.ACCESS_FINE_LOCATION
});
}
}
Upgrading from 1.x
Breaking Changes
SDK distribution moved from JitPack to GitHub Packages — Remove JitPack from your repository configuration and replace with GitHub Packages as described in the Installation section above.
// Before (remove this) maven { url "https://jitpack.io" credentials { username "<accessToken>" } } // Before (remove this) implementation 'com.gitlab.landmarksid:sdk-android-lo:1.6.6' // After implementation 'com.landmarksid:landmarks-android-sdk-lo:2.0.0'Optionsis now a standalone class — PreviouslyLandmarksID.Options, nowcom.landmarksid.lo.core.Options.// Before LandmarksID.Options options = new LandmarksID.Options() .setApiKey(API_KEY); // After Options options = new Options() .setApiKey(API_KEY);setLocationUsable(Activity)is deprecated — The SDK now handles permission state automatically when you callonRequestPermissionsResult(). Remove all calls tosetLocationUsable().// Before @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { landmarksId.onRequestPermissionsResult(this, requestCode, permissions, grantResults); if (permissionGranted) { landmarksId.setLocationUsable(this); // REMOVE THIS } } // After @Override public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { landmarksId.onRequestPermissionsResult(this, requestCode, permissions, grantResults); // That's it — the SDK handles the rest }setLocationUsable()should not be called at startup — Previously some apps calledsetLocationUsable()immediately afterstart()to bootstrap location services. This is no longer needed.// Before landmarksId = LandmarksID.getInstance().start(this, options); landmarksId.setLocationUsable(this); // REMOVE THIS // After landmarksId = LandmarksID.getInstance().start(this, options);
Contact Details
If you have any further questions please do not hesitate to contact our friendly team at;
