本文整理汇总了Java中android.location.Location.getLongitude方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getLongitude方法的具体用法?Java Location.getLongitude怎么用?Java Location.getLongitude使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.location.Location
的用法示例。
在下文中一共展示了Location.getLongitude方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onListItemClick
import android.location.Location; //导入方法依赖的package包/类
@Override
protected void onListItemClick(ListView l, View v, int position, long id) {
Location loc = (Location) l.getAdapter().getItem(position);
Toast.makeText(this, loc.getLatitude() + " " + loc.getLongitude(), Toast.LENGTH_SHORT).show();
//simplesmente centraliza o mapa na latitude/longitude escolhida
//nao amarra com google maps
String locData = "geo:"+loc.getLatitude()+","+loc.getLongitude();
//abre streetview
locData = "google.streetview:cbll="+loc.getLatitude()+","+loc.getLongitude();
//abre navigation
//locData = "google.navigation:q="+loc.getLatitude()+","+loc.getLongitude();
Uri locationURI = Uri.parse(locData);
Intent i = new Intent(Intent.ACTION_VIEW, locationURI);
if (i.resolveActivity(getPackageManager()) != null) {
startActivity(i);
}
}
示例2: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
currentLatitude = location.getLatitude();
currentLongitude = location.getLongitude();
//Toast.makeText(this, currentLatitude + " WORKS " + currentLongitude + "", Toast.LENGTH_LONG).show();
LatLng latLng = new LatLng(currentLatitude, currentLongitude);
googleMap.addMarker(new MarkerOptions().position(latLng));
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(latLng, 15));
googleMap.animateCamera(CameraUpdateFactory.zoomIn());
googleMap.animateCamera(CameraUpdateFactory.zoomTo(15), 2000, null);
getNearByClinics(currentLongitude, currentLatitude);
}
示例3: getCurrentLocation
import android.location.Location; //导入方法依赖的package包/类
private void getCurrentLocation() {
mMap.clear();
if(ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_FINE_LOCATION)!= PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this,android.Manifest.permission.ACCESS_COARSE_LOCATION)!=PackageManager.PERMISSION_GRANTED )
{
//Creating a location object
return ;}
Location location = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);
if (location != null) {
//Getting longitude and latitude
longitude = location.getLongitude();
latitude = location.getLatitude();
//moving the map to location
moveMap();
}
}
示例4: gotoLocation
import android.location.Location; //导入方法依赖的package包/类
/**
* For actually moving the map to the desired location.
* @param fctx
* @param loc
*/
public static void gotoLocation(Activity fctx, Location loc) {
Location locc = loc;
sloc = loc;
if(loc == null){
locc = getCurrentLocation(fctx);
}
if(code == AddHabitEventActivity.EVENT_PERMISSION_CHECK){
}
float zoom = 15.0f;
if(locc == null){
DummyMainActivity.toastMe("Could not get location", fctx);
}else{
double[] d = {locc.getLatitude(), locc.getLongitude()};
AddHabitEventActivity.setLocation(d);
LatLng ll = new LatLng(locc.getLatitude(), locc.getLongitude());
CameraUpdate update = CameraUpdateFactory.newLatLngZoom(ll, zoom);
gmap.moveCamera(update);
}
}
示例5: getLocation
import android.location.Location; //导入方法依赖的package包/类
public static String getLocation(Context context) {
if (context == null) {
return "";
}
try {
LocationManager locationManager = (LocationManager) context.getSystemService(HOME_RECOMMEND_PARAMETERS.LOCATION);
Criteria criteria = new Criteria();
criteria.setCostAllowed(false);
criteria.setAccuracy(2);
String bestProvider = locationManager.getBestProvider(criteria, true);
if (bestProvider != null) {
Location lastKnownLocation = locationManager.getLastKnownLocation(bestProvider);
if (lastKnownLocation == null) {
return "";
}
double latitude = lastKnownLocation.getLatitude();
g = latitude + "*" + lastKnownLocation.getLongitude();
return g;
}
} catch (Throwable e) {
f.b("getLocation", "getLocation>>>", e);
}
return "";
}
示例6: checkInterval
import android.location.Location; //导入方法依赖的package包/类
private void checkInterval(Location location) {
if (location == null) {
return;
}
if (!isValidState()) {
distanceInterval = 0;
recentSpeed = 0;
return;
}
recentSpeed = location.getSpeed();
if (!isValidSpeed()) {
return;
}
double distance = 0;
if (prevLatitude != location.getLatitude()
|| prevLongitude != location.getLongitude()) {
distance = calcDistance(location);
}
// enable fake speed for tests:
if (BuildConfig.FAKE) {
distance += 20;
}
prevLatitude = location.getLatitude();
prevLongitude = location.getLongitude();
prevAltitude = location.getAltitude();
if (distance < intervalLength) {
distanceInterval += distance;
} else {
sendOnIntervalChanged(distanceInterval, false);
distanceInterval = 0;
return;
}
if (distanceInterval >= intervalLength) {
boolean correctData = distanceInterval < MAX_DISTANCE;
sendOnIntervalChanged(distanceInterval, correctData);
distanceInterval = 0;
}
}
示例7: LocSample
import android.location.Location; //导入方法依赖的package包/类
LocSample(Location l) {
super();
Latitude = l.getLatitude();
Longitude = l.getLongitude();
Alt = (int) (l.getAltitude() * MFBConstants.METERS_TO_FEET);
Speed = l.getSpeed() * MFBConstants.MPS_TO_KNOTS;
HError = l.getAccuracy();
TimeStamp.setTime(l.getTime());
TZOffset = 0;
}
示例8: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
Log.e("lococococ", String.valueOf(location.getLatitude()));
latlong=location.getLatitude()+","+location.getLongitude();
lat=location.getLatitude();
longi=location.getLongitude();
go();
}
示例9: setLatLong
import android.location.Location; //导入方法依赖的package包/类
public void setLatLong(Location location) {
double lastLat = location.getLatitude();
double lastLong = location.getLongitude();
SharedPreferences.Editor edit = preferences.edit();
edit.putString("last_gps_lat", String.valueOf(lastLat));
edit.putString("last_gps_long", String.valueOf(lastLong));
edit.apply();
}
示例10: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location l) {
if (l != null) {
userLocation = new LatLng(l.getLatitude(), l.getLongitude());
if (mUser.getUserID() != null) {
mDatabase.child("users").child(mUser.getUserID()).child("latitude").setValue(userLocation.latitude);
mDatabase.child("users").child(mUser.getUserID()).child("longitude").setValue(userLocation.longitude);
} else {
Toast.makeText(getApplicationContext(), "Current user not recognized. Try reauthenticating.",
Toast.LENGTH_LONG).show();
}
}
}
示例11: contains
import android.location.Location; //导入方法依赖的package包/类
/**
* @param point {@link Location} object
* @return location contains in box
*/
public boolean contains(Location point) {
return point.getLatitude() >= minLatitude
&& point.getLongitude() >= minLongitude
&& point.getLatitude() <= maxLatitude
&& point.getLongitude() <= maxLongitude;
}
示例12: locationUpdates
import android.location.Location; //导入方法依赖的package包/类
@Override
public void locationUpdates(Location location)
{
double currentLatitude = location.getLatitude();
double currentLongitude = location.getLongitude();
Toast.makeText(MainActivity.this, "Latitude: " + currentLatitude + "" + " Longitude: " + currentLongitude + "", Toast.LENGTH_LONG).show();
}
示例13: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
float latitude = (float) location.getLatitude();
float longitude = (float) location.getLongitude();
float altitude = (float) location.getAltitude();
for (SensorInfo sensorInfo : sensorInfos) {
if (sensorInfo.getType() == SensorType.GPS) {
sensorInfo.setValues(new float[]{latitude, longitude, altitude});
break;
}
}
}
示例14: onLocationChanged
import android.location.Location; //导入方法依赖的package包/类
@Override
public void onLocationChanged(Location location) {
Log.d("onLocationChanged", "entered");
mLastLocation = location;
if (mCurrLocationMarker != null) {
mCurrLocationMarker.remove();
}
//Place current location marker
latitude = location.getLatitude();
longitude = location.getLongitude();
LatLng latLng = new LatLng(location.getLatitude(), location.getLongitude());
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(latLng);
markerOptions.title("Current Position");
markerOptions.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_MAGENTA));
mCurrLocationMarker = mMap.addMarker(markerOptions);
//move map camera
mMap.moveCamera(CameraUpdateFactory.newLatLng(latLng));
mMap.animateCamera(CameraUpdateFactory.zoomTo(11));
Toast.makeText(MapsActivity2.this,"Your Current Location", Toast.LENGTH_LONG).show();
Log.d("onLocationChanged", String.format("latitude:%.3f longitude:%.3f",latitude,longitude));
//stop location updates
if (mGoogleApiClient != null) {
LocationServices.FusedLocationApi.removeLocationUpdates(mGoogleApiClient, this);
Log.d("onLocationChanged", "Removing Location Updates");
}
Log.d("onLocationChanged", "Exit");
}
示例15: checkIsDataAvailableForRecord
import android.location.Location; //导入方法依赖的package包/类
private boolean checkIsDataAvailableForRecord() {
GPSDetector gpsDetector = getGPSDetector();
if (gpsDetector == null ||
!gpsDetector.isValidSpeed() || !gpsDetector.isValidState()) {
return false;
}
Location loc = gpsDetector.getLocation();
if (loc == null) {
return false;
}
double latitude = loc.getLatitude();
double longitude = loc.getLongitude();
double altitude = loc.getAltitude();
curSpeed = loc.getSpeed();
double distance = 0;
if (latitude >= 0 && longitude >= 0) {
distance = calcDistance(latitude, longitude);
if (curLatitude != latitude && curLongitude != longitude) {
curLatitude = latitude;
curLongitude = longitude;
curAltitude = altitude;
//Log.d(TAG, "curLatitude= " + curLatitude + ", curLongitude= "
//+ curLongitude + ", distance= " + distance);
}
}
if (distance >= MIN_DISTANCE) {
curDistance = distance;
Log.d(TAG, "data available for record, distance= " + distance);
return true;
}
return false;
}