android - FusedLocationProviderApi.KEY_LOCATION_CHANGED deprecated. What to do now? -
i had locationreceiver
used fusedlocationproviderapi.key_location_changed
extract location
intent
. key_location_changed
deprecated should change to?
current code:
@override public void onreceive(context context, intent intent) { final location location = (location) intent.getextras().get(fusedlocationproviderapi.key_location_changed); if (location != null) { float accuracy = location.getaccuracy(); log.d(locationreceiver.class.getsimplename(), "*** accuracy is: " + accuracy + " ***"); } else { log.d(locationreceiver.class.getsimplename(), "*** location object null ***"); } }
after research found answer:
@override public void onreceive(context context, intent intent) { if (locationresult.hasresult(intent)) { locationresult locationresult = locationresult.extractresult(intent); location location = locationresult.getlastlocation(); if (location != null) { // use location } } }
Comments
Post a Comment