Search in sources :

Example 1 with LocationInfoManager

use of org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager in project prebid-mobile-android by prebid.

the class BaseJSInterface method getLocation.

@Override
@JavascriptInterface
public String getLocation() {
    LocationInfoManager locationInfoManager = ManagersResolver.getInstance().getLocationManager();
    JSONObject location = new JSONObject();
    if (locationInfoManager.isLocationAvailable()) {
        try {
            location.put(LOCATION_LAT, locationInfoManager.getLatitude());
            location.put(LOCATION_LON, locationInfoManager.getLongitude());
            // type - static value "1" - GPS provider
            location.put(LOCATION_TYPE, GeoLocationParameterBuilder.LOCATION_SOURCE_GPS);
            location.put(LOCATION_ACCURACY, locationInfoManager.getAccuracy());
            location.put(LOCATION_LASTFIX, locationInfoManager.getElapsedSeconds());
            return location.toString();
        } catch (JSONException e) {
            LogUtil.error(TAG, "MRAID: Error providing location: " + Log.getStackTraceString(e));
        }
    }
    return LOCATION_ERROR;
}
Also used : JSONObject(org.json.JSONObject) LocationInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager) JSONException(org.json.JSONException) JavascriptInterface(android.webkit.JavascriptInterface)

Example 2 with LocationInfoManager

use of org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager in project prebid-mobile-android by prebid.

the class GeoLocationParameterBuilder method appendBuilderParameters.

@Override
public void appendBuilderParameters(AdRequestInput adRequestInput) {
    LocationInfoManager locationInfoManager = ManagersResolver.getInstance().getLocationManager();
    DeviceInfoManager deviceManager = ManagersResolver.getInstance().getDeviceManager();
    // Strictly ignore publisher geo values
    adRequestInput.getBidRequest().getDevice().setGeo(null);
    if (locationInfoManager != null) {
        if (deviceManager != null && deviceManager.isPermissionGranted("android.permission.ACCESS_FINE_LOCATION")) {
            setLocation(adRequestInput, locationInfoManager);
        }
    }
}
Also used : LocationInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager) DeviceInfoManager(org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)

Aggregations

LocationInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.LocationInfoManager)2 JavascriptInterface (android.webkit.JavascriptInterface)1 JSONException (org.json.JSONException)1 JSONObject (org.json.JSONObject)1 DeviceInfoManager (org.prebid.mobile.rendering.sdk.deviceData.managers.DeviceInfoManager)1