use of com.google.android.gms.location.LocationResult in project android-play-location by googlesamples.
the class LocationUpdatesBroadcastReceiver method onReceive.
@Override
public void onReceive(Context context, Intent intent) {
if (intent != null) {
final String action = intent.getAction();
if (ACTION_PROCESS_UPDATES.equals(action)) {
LocationResult result = LocationResult.extractResult(intent);
if (result != null) {
List<Location> locations = result.getLocations();
Utils.setLocationUpdatesResult(context, locations);
Utils.sendNotification(context, Utils.getLocationResultTitle(context, locations));
Log.i(TAG, Utils.getLocationUpdatesResult(context));
}
}
}
}
use of com.google.android.gms.location.LocationResult in project android-play-location by googlesamples.
the class LocationUpdatesService method onCreate.
@Override
public void onCreate() {
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this);
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
super.onLocationResult(locationResult);
onNewLocation(locationResult.getLastLocation());
}
};
createLocationRequest();
getLastLocation();
HandlerThread handlerThread = new HandlerThread(TAG);
handlerThread.start();
mServiceHandler = new Handler(handlerThread.getLooper());
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
// Android O requires a Notification Channel.
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
CharSequence name = getString(R.string.app_name);
// Create the channel for the notification
NotificationChannel mChannel = new NotificationChannel(CHANNEL_ID, name, NotificationManager.IMPORTANCE_DEFAULT);
// Set the Notification Channel for the Notification Manager.
mNotificationManager.createNotificationChannel(mChannel);
}
}
use of com.google.android.gms.location.LocationResult in project Walrus by megabug.
the class ProjectWalrusApplication method startLocationUpdates.
public static void startLocationUpdates() {
FusedLocationProviderClient fusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(context);
LocationRequest locationRequest = LocationRequest.create();
locationRequest.setInterval(2000);
locationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
try {
fusedLocationProviderClient.requestLocationUpdates(locationRequest, new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
for (Location location : locationResult.getLocations()) {
if (currentBestLocation == null || GeoUtils.isBetterLocation(location, currentBestLocation))
currentBestLocation = location;
}
}
}, null);
} catch (SecurityException ignored) {
}
}
use of com.google.android.gms.location.LocationResult in project GogoNew by kuldeep725.
the class MapsActivity method onLocationChanged.
@Override
public void onLocationChanged(Location location) {
Log.e(TAG, "Firing onLocationChanged..............................................");
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
for (Location location : locationResult.getLocations()) {
// Update UI with location data
// ...
mCurrentLocation = location;
Log.e(TAG, "@onLocationChanged--> mCurrentLocation");
}
}
};
}
use of com.google.android.gms.location.LocationResult in project TrekAdvisor by peterLaurence.
the class MapViewFragment method onAttach.
@Override
public void onAttach(Context context) {
super.onAttach(context);
if (context instanceof RequestManageTracksListener && context instanceof RequestManageMarkerListener && context instanceof MapProvider) {
mRequestManageTracksListener = (RequestManageTracksListener) context;
mRequestManageMarkerListener = (RequestManageMarkerListener) context;
mMapProvider = (MapProvider) context;
} else {
throw new RuntimeException(context.toString() + " must implement RequestManageTracksListener, MapProvider and LocationProvider");
}
/* The Google api client is re-created here as the onAttach method will always be called for
* a retained fragment.
*/
mFusedLocationClient = LocationServices.getFusedLocationProviderClient(this.getActivity().getApplicationContext());
mLocationRequest = new LocationRequest();
mLocationRequest.setInterval(1000);
mLocationRequest.setFastestInterval(1000);
mLocationRequest.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY);
mLocationCallback = new LocationCallback() {
@Override
public void onLocationResult(LocationResult locationResult) {
for (Location location : locationResult.getLocations()) {
onLocationReceived(location);
}
}
};
}
Aggregations