LocationDisplay shows initial location, doesn't move

210
2
05-31-2019 01:27 PM
ChristopherSwingley
New Contributor II

I'm trying to migrate from the old SDK to 100.5 and am having trouble with the simplest of things: drawing a map and showing the device location. I can get the "Display Device Location" example to run, but as soon as I remove the Spinner and try to start up the app with location display started, I get the blue dot showing the current location, but when I move, the dot doesn't. It knows I'm moving because the directional arrow in the middle of the blue dot shows the correct heading, but the dot itself doesn't move. Here's what the onCreate method looks like within MainActivity. I've also overridden onRequestPermissionsResult like the example.

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

if (!(ContextCompat.checkSelfPermission(MainActivity.this, reqPermissions[0]) == PackageManager.PERMISSION_GRANTED &&
ContextCompat.checkSelfPermission(MainActivity.this, reqPermissions[1]) == PackageManager.PERMISSION_GRANTED)) {
int requestCode = 2;
ActivityCompat.requestPermissions(MainActivity.this, reqPermissions, requestCode);
}

mMapView = findViewById(R.id.mapView);
final ArcGISMap map = new ArcGISMap(Basemap.createTopographic());
mMapView.setMap(map);

mLocationDisplay = mMapView.getLocationDisplay();
mLocationDisplay.setAutoPanMode(LocationDisplay.AutoPanMode.RECENTER);
mLocationDisplay.startAsync();
}

What am I missing? Does the startAsync() need to be somewhere other than onCreate?

Tags (2)
0 Kudos
2 Replies
ChanganShi
Esri Contributor

Do you have the uses-permission in the manifest file?

<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
0 Kudos
ChristopherSwingley
New Contributor II

Yes, I do, thanks. I have everything the "Display Device Location" example has (INTERNET and the two location permissions you mention), plus read/write external storage, wifi, network, and phone state permissions.

0 Kudos