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);
// }
}
});
}
use of android.location.Location in project Pokemap by omkarmoghe.
the class PokemonNotificationService method onEvent.
@Subscribe
public void onEvent(CatchablePokemonEvent event) {
List<CatchablePokemon> catchablePokemon = event.getCatchablePokemon();
LatLng location = locationManager.getLocation();
Location myLoc = new Location("");
myLoc.setLatitude(location.latitude);
myLoc.setLongitude(location.longitude);
builder.setContentText(getString(R.string.notification_service_pokemon_near, catchablePokemon.size()));
builder.setStyle(null);
if (!catchablePokemon.isEmpty()) {
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(getString(R.string.notification_service_pokemon_in_area, catchablePokemon.size()));
Set<PokemonIdOuterClass.PokemonId> showablePokemonIDs = preffs.getShowablePokemonIDs();
for (CatchablePokemon cp : catchablePokemon) {
//Only show the notification if the Pokemon is in the preference list
if (showablePokemonIDs.contains(cp.getPokemonId())) {
Location pokeLocation = new Location("");
pokeLocation.setLatitude(cp.getLatitude());
pokeLocation.setLongitude(cp.getLongitude());
long remainingTime = cp.getExpirationTimestampMs() - System.currentTimeMillis();
String pokeName = PokemonIdUtils.getLocalePokemonName(getApplicationContext(), cp.getPokemonId().name());
long remTime = TimeUnit.MILLISECONDS.toMinutes(remainingTime);
int dist = (int) Math.ceil(pokeLocation.distanceTo(myLoc));
inboxStyle.addLine(getString(R.string.notification_service_inbox_line, pokeName, remTime, dist));
}
}
builder.setStyle(inboxStyle);
}
NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
nm.notify(notificationId, builder.build());
}
use of android.location.Location in project Pokemap by omkarmoghe.
the class MapWrapperFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
locationManager = LocationManager.getInstance(getContext());
nianticManager = NianticManager.getInstance();
locationManager.register(new LocationManager.Listener() {
@Override
public void onLocationChanged(Location location) {
if (mLocation == null) {
mLocation = location;
initMap(true, true);
} else {
mLocation = location;
}
}
@Override
public void onLocationFetchFailed(@Nullable ConnectionResult connectionResult) {
showLocationFetchFailed();
}
});
// Inflate the layout for this fragment if the view is not null
if (mView == null)
mView = inflater.inflate(R.layout.fragment_map_wrapper, container, false);
else {
}
// build the map
if (mSupportMapFragment == null) {
mSupportMapFragment = SupportMapFragment.newInstance();
getChildFragmentManager().beginTransaction().replace(R.id.map, mSupportMapFragment).commit();
mSupportMapFragment.setRetainInstance(true);
}
if (mGoogleMap == null) {
mSupportMapFragment.getMapAsync(this);
}
FloatingActionButton locationFab = (FloatingActionButton) mView.findViewById(R.id.location_fab);
locationFab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mLocation != null && mGoogleMap != null) {
mGoogleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(mLocation.getLatitude(), mLocation.getLongitude()), 15));
} else {
showLocationFetchFailed();
}
}
});
mView.findViewById(R.id.closeSuggestions).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hideMapSuggestion();
}
});
if (!mPref.getShowMapSuggestion()) {
hideMapSuggestion();
}
return mView;
}
use of android.location.Location in project robolectric by robolectric.
the class ShadowLocationManager method copyOf.
private Location copyOf(Location location) {
if (location == null)
return null;
Location copy = new Location(location);
copy.setAccuracy(location.getAccuracy());
copy.setAltitude(location.getAltitude());
copy.setBearing(location.getBearing());
copy.setExtras(location.getExtras());
copy.setLatitude(location.getLatitude());
copy.setLongitude(location.getLongitude());
copy.setProvider(location.getProvider());
copy.setSpeed(location.getSpeed());
copy.setTime(location.getTime());
return copy;
}
Aggregations