setContentView(R.layout.main);
wargps = (EditText) findViewById(R.id.wargps);
locbtn = (Button) findViewById(R.id.locbtn);
locbtn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
FusedLocationProviderClient fusedLocationProviderClient =
LocationServices.getFusedLocationProviderClient(getApplicationContext());
Task task = fusedLocationProviderClient.getLastLocation();
task.addOnSuccessListener(new OnSuccessListener() {
@Override
public void onSuccess(Location location) {
if(location!=null) {
wargps.setText(location.getLatitude()+" "+location.getLongitude());
locbtn.setText("Got Location");
}}});
}
});
Nothing fancy, just a personal log with a built in search function so I can recall what is easily forgotten.
Saturday, April 20, 2019
Android FusedLocationProviderClient
In hopes of obtaining GPS location faster, I implemented the FusedLocationProviderClient and removed the old LocationManager.GPS_PROVIDER. Below is a snippet of the new simpler approach that I used in the latest update of Widespread Augmented Reality.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment