use of android.location.Location in project android_frameworks_base by ParanoidAndroid.
the class ExternalSharedPermsFLTest method testRunFineLocation.
/** The use of location manager below is simply to simulate an app that
* tries to use it, so we can verify whether permissions are granted and accessible.
* */
public void testRunFineLocation() {
LocationManager locationManager = (LocationManager) getInstrumentation().getContext().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, new LocationListener() {
public void onLocationChanged(Location location) {
}
public void onProviderDisabled(String provider) {
}
public void onProviderEnabled(String provider) {
}
public void onStatusChanged(String provider, int status, Bundle extras) {
}
});
}
use of android.location.Location in project android_frameworks_base by ParanoidAndroid.
the class FusionEngine method updateFusedLocation.
private void updateFusedLocation() {
// may the best location win!
if (isBetterThan(mGpsLocation, mNetworkLocation)) {
mFusedLocation = new Location(mGpsLocation);
} else {
mFusedLocation = new Location(mNetworkLocation);
}
mFusedLocation.setProvider(FUSED);
if (mNetworkLocation != null) {
// copy NO_GPS_LOCATION extra from mNetworkLocation into mFusedLocation
Bundle srcExtras = mNetworkLocation.getExtras();
if (srcExtras != null) {
Parcelable srcParcelable = srcExtras.getParcelable(LocationProviderBase.EXTRA_NO_GPS_LOCATION);
if (srcParcelable instanceof Location) {
Bundle dstExtras = mFusedLocation.getExtras();
if (dstExtras == null) {
dstExtras = new Bundle();
mFusedLocation.setExtras(dstExtras);
}
dstExtras.putParcelable(LocationProviderBase.EXTRA_NO_GPS_LOCATION, (Location) srcParcelable);
}
}
}
if (mCallback != null) {
mCallback.reportLocation(mFusedLocation);
} else {
Log.w(TAG, "Location updates received while fusion engine not started");
}
}
use of android.location.Location in project ignition by mttkay.
the class AbstractIgnitedLocationManagerTest method ignitedLocationIsCurrentLocation.
@Test
public void ignitedLocationIsCurrentLocation() {
resume();
assertThat(lastKnownLocation, equalTo(activity.getCurrentLocation()));
Location newLocation = sendMockLocationBroadcast(LocationManager.GPS_PROVIDER);
assertThat(newLocation, equalTo(activity.getCurrentLocation()));
}
use of android.location.Location in project ignition by mttkay.
the class AbstractIgnitedLocationManagerTest method sendMockLocationBroadcast.
protected Location sendMockLocationBroadcast(String provider, float accuracy, String action) {
Intent intent = new Intent(action);
Location location = getMockLocation(2.0, 2.0);
intent.putExtra(LocationManager.KEY_LOCATION_CHANGED, location);
shadowApp.sendBroadcast(intent);
return location;
}
use of android.location.Location in project android-app-common-tasks by multidots.
the class GetCurrentLocationAct method init.
private void init() {
tvLatitude = (TextView) findViewById(R.id.tvLatitude);
tvLongitude = (TextView) findViewById(R.id.tvLongitude);
Button btnLocation = (Button) findViewById(R.id.btnLocation);
btnLocation.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// if (Common.isNetworkAvailable(mContext)) {
// if (Common.getGpsStatus(mContext)) {
Location location = Common.getCurrentLocation(mContext);
if (location != null) {
tvLatitude.setText("" + location.getLatitude());
tvLongitude.setText("" + location.getLongitude());
} else {
Common.showGPSDisabledAlert("Please enable your location or connect to cellular network.", GetCurrentLocationAct.this);
}
// } else {
// Common.showGPSDisabledAlert("Please enable your location.", mContext);
// }
// } else {
// Toast.makeText(mContext, "Please Connect your device with internet.", Toast.LENGTH_LONG).show();
// Common.showNETWORDDisabledAlert(mContext);
// }
}
});
}
Aggregations