onLocationChanged not being called within the IndoorAtlas location manager

295 views Asked by At

When testing I am able to receive updates from the onStatusChanged within the IALocationListener, but the onLocationChanged is not being called. Any ideas as to why this is?

I have followed the instructions from IndoorAtlas (http://docs.indooratlas.com/android/dev-guide/getting-user-location.html) as well as a video from YouTube (https://www.youtube.com/watch?v=2EXkV4xL5rg) but was still not able to get the location.

Do I have to be in the area that I have mapped or should it read the location no matter where I am?

package com.bignerdranch.android.indoormapping;

import android.Manifest;
import android.support.v4.app.ActivityCompat;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.os.Bundle;
import android.util.Log;

import com.indooratlas.android.sdk.IALocation;
import com.indooratlas.android.sdk.IALocationListener;
import com.indooratlas.android.sdk.IALocationManager;
import com.indooratlas.android.sdk.IALocationRequest;

public class MappingActivity extends FragmentActivity {

    private final int CODE_PERMISSIONS = 0;
    private IALocationManager mIALocationManager;
    private static final String TAG = "LocateActivity";

    private IALocationListener mIALocationListener = new IALocationListener() {
        @Override
        public void onLocationChanged(IALocation iaLocation) {
            Log.d(TAG, "Latitude: " + iaLocation.getLatitude());
        }

        @Override
        public void onStatusChanged(String s, int i, Bundle bundle) {

        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mapping);

        mIALocationManager = IALocationManager.create(this);



        // request permissions for coarse location and Wifi
        String[] neededPermissions = {
                Manifest.permission.CHANGE_WIFI_STATE,
                Manifest.permission.ACCESS_WIFI_STATE,
                Manifest.permission.ACCESS_COARSE_LOCATION
        };
        ActivityCompat.requestPermissions( this, neededPermissions, CODE_PERMISSIONS );

        FragmentManager fm = getSupportFragmentManager();
        Fragment fragment = fm.findFragmentById(R.id.fragment_cont);

        if(fragment == null) {
            fragment = new MappingFragment();
            fm.beginTransaction()
                    .add(R.id.fragment_cont, fragment)
                    .commit();
        }
    }

    // handle any permissions that are denied
    @Override
    public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
        super.onRequestPermissionsResult(requestCode, permissions, grantResults);
    }

    @Override
    public void onResume() {
        super.onResume();
        mIALocationManager.requestLocationUpdates(IALocationRequest.create(), mIALocationListener);
    }

    @Override
    public void onPause() {
        super.onPause();
        mIALocationManager.removeLocationUpdates(mIALocationListener);
    }
}
1

There are 1 answers

0
Neel0507 On

Here IndoorAtlas has given some code examples of their SDK. You should be able to find the issue.