import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.geolocstation.GeolocStation;
import com.geolocstation.consent.GeolocStationConsent;
import io.didomi.sdk.Didomi;
public class Activity extends AppCompatActivity {
private Didomi didomi = Didomi.getInstance();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
GeolocStation.requestLocationPermission(this);
Log.d("DIDOMI", "Didomi SDK is ready");
// Pass the user consent status to GeolocStation when the app is launched
setGeolocStationSdkConsents();
didomi.addEventListener(new EventListener() {
public void consentChanged(ConsentChangedEvent event) {
// Pass the user consent status to GeolocStation when the user consent status changes
setGeolocStationSdkConsents();
Log.d("DIDOMI", Log.getStackTraceString(e));
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
GeolocStation.onRequestPermissionsResult(this);
* Pass the user consent status to GeolocStation
public void setGeolocStationSdkConsents() {
Boolean consentStatusForTeemo = didomi.getUserConsentStatusForVendor("teemo");
if(consentStatusForTeemo ) {
Boolean advertising = didomi.getUserConsentStatusForPurpose("geolocation_for_advertising");
Boolean analytics = didomi.getUserConsentStatusForPurpose("geolocation_for_analytics");
GeolocStationConsent.setConsents(this.getApplicationContext(),
advertising != null ? advertising : false,
analytics != null ? analytics : false);
GeolocStationConsent.setConsents(this.getApplicationContext(), false, false);