當前位置: 首頁>>代碼示例>>Java>>正文


Java Location.hasBearing方法代碼示例

本文整理匯總了Java中android.location.Location.hasBearing方法的典型用法代碼示例。如果您正苦於以下問題:Java Location.hasBearing方法的具體用法?Java Location.hasBearing怎麽用?Java Location.hasBearing使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.location.Location的用法示例。


在下文中一共展示了Location.hasBearing方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCurrent

import android.location.Location; //導入方法依賴的package包/類
@Override
public String getCurrent() {
    if (infoCollector != null) {
        String locationBearingString = "";
        final Location loc = infoCollector.getLocationInfo();
        if (loc != null && loc.hasBearing() && Helperfunctions.getAge(loc) < 3000000000L) {
            locationBearingString = String.format("%.0f %s", loc.getBearing(), "°");
        } else {
            locationBearingString = context.getString(R.string.not_available);
        }

        return locationBearingString;
    }

    return null;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:17,代碼來源:LocationBearingItem.java

示例2: convertNmeaRMC

import android.location.Location; //導入方法依賴的package包/類
public static String convertNmeaRMC(Location paramLocation) {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("$GPRMC,");
    localStringBuilder.append(FormatUTCDate("HHmmss.SSS", new Date(paramLocation.getTime())));
    localStringBuilder.append(",A,");
    localStringBuilder.append(FormatLatLon("%02d%08.5f,%c,", 'S', 'N', paramLocation.getLatitude()));
    localStringBuilder.append(FormatLatLon("%03d%08.5f,%c,", 'W', 'E', paramLocation.getLongitude()));
    if (paramLocation.hasSpeed()) {
        localStringBuilder.append(String.format(Locale.getDefault(), "%5.3f", paramLocation.getSpeed() / 0.5395720670123687D));
    }
    localStringBuilder.append(",");
    if (paramLocation.hasBearing()) {
        localStringBuilder.append(String.format(Locale.getDefault(), "%1.0f", (double) paramLocation.getBearing()));
    }
    localStringBuilder.append(",");
    localStringBuilder.append(FormatUTCDate("ddMMyy", new Date(paramLocation.getTime())));
    localStringBuilder.append(",,,A");
    localStringBuilder.append(calcNmeaCrc(localStringBuilder));
    return localStringBuilder.toString();
}
 
開發者ID:MaoJianwei,項目名稱:Android_GPS_NMEA_Server_Reader_Sender,代碼行數:21,代碼來源:MaoNmeaTools.java

示例3: convertNmeaVTG

import android.location.Location; //導入方法依賴的package包/類
public static String convertNmeaVTG(Location paramLocation) {
    StringBuilder localStringBuilder = new StringBuilder();
    localStringBuilder.append("$GPVTG,");
    if (paramLocation.hasBearing()) {
        localStringBuilder.append(String.format(Locale.getDefault(), "%1.0f", paramLocation.getBearing()));
    }
    localStringBuilder.append(",T,,M,");
    if (paramLocation.hasSpeed()) {
        localStringBuilder.append(String.format(Locale.getDefault(), "%5.3f,N,%5.3f,K,",
                paramLocation.getSpeed() / 0.5395720670123687D, 3.6D * paramLocation.getSpeed()));
    } else {
        localStringBuilder.append(",,,,");
    }
    localStringBuilder.append(calcNmeaCrc(localStringBuilder));
    return localStringBuilder.toString();
}
 
開發者ID:MaoJianwei,項目名稱:Android_GPS_NMEA_Server_Reader_Sender,代碼行數:17,代碼來源:MaoNmeaTools.java

示例4: writeLocation

import android.location.Location; //導入方法依賴的package包/類
/**
 * Write location to database.
 *
 * @param loc Location
 */
void writeLocation(Location loc) {
    if (Logger.DEBUG) { Log.d(TAG, "[writeLocation]"); }
    ContentValues values = new ContentValues();
    values.put(DbContract.Positions.COLUMN_TIME, loc.getTime() / 1000);
    values.put(DbContract.Positions.COLUMN_LATITUDE, loc.getLatitude());
    values.put(DbContract.Positions.COLUMN_LONGITUDE, loc.getLongitude());
    if (loc.hasBearing()) {
        values.put(DbContract.Positions.COLUMN_BEARING, loc.getBearing());
    }
    if (loc.hasAltitude()) {
        values.put(DbContract.Positions.COLUMN_ALTITUDE, loc.getAltitude());
    }
    if (loc.hasSpeed()) {
        values.put(DbContract.Positions.COLUMN_SPEED, loc.getSpeed());
    }
    if (loc.hasAccuracy()) {
        values.put(DbContract.Positions.COLUMN_ACCURACY, loc.getAccuracy());
    }
    values.put(DbContract.Positions.COLUMN_PROVIDER, loc.getProvider());

    db.insert(DbContract.Positions.TABLE_NAME, null, values);
}
 
開發者ID:bfabiszewski,項目名稱:ulogger-android,代碼行數:28,代碼來源:DbAccess.java

示例5: updateLocation

import android.location.Location; //導入方法依賴的package包/類
private void updateLocation(Location location) {
  this.location = location;
  if (location == null) {
    locationUpdateTimestamp = SystemClock.elapsedRealtime();
    return;
  }
  if (locationLayerMode == LocationLayerMode.NAVIGATION && location.hasBearing()) {
    bearingChangeAnimate(location.getBearing());
  } else if (locationLayerMode != LocationLayerMode.NAVIGATION) {
    locationLayer.updateAccuracyRadius(location);
  }
  setLocation(location);
}
 
開發者ID:mapbox,項目名稱:mapbox-plugins-android,代碼行數:14,代碼來源:LocationLayerPlugin.java

示例6: onLocationChanged

import android.location.Location; //導入方法依賴的package包/類
@Override
public void onLocationChanged(final Location location) {
    LogHelper.debugLog(TAG,
            "File name: \"" +
                    Thread.currentThread().getStackTrace()[2].getFileName() +
                    "\", Line number: " +
                    Thread.currentThread().getStackTrace()[2].getLineNumber() +
                    ", Class name: \"" +
                    Thread.currentThread().getStackTrace()[2].getClassName() +
                    "\", Method name: \"" +
                    Thread.currentThread().getStackTrace()[2].getMethodName() +
                    "\"");

    LogHelper.infoLog(TAG, "Location changed: " + location);

    LogHelper.infoLog(TAG, "Changed location provider: " + location.getProvider());

    LogHelper.infoLog(TAG, "Changed location latitude: " + location.getLatitude());

    LogHelper.infoLog(TAG, "Changed location longitude: " + location.getLongitude());

    LogHelper.infoLog(TAG, "Changed location time: " + location.getTime());

    LogHelper.infoLog(TAG, "Changed location elapsed realtime nanos: " + location.getElapsedRealtimeNanos());

    LogHelper.infoLog(TAG, "Changed location extras: " + location.getExtras());

    if (location.hasAccuracy()) {
        LogHelper.infoLog(TAG, "Changed location has accuracy: " + location.getAccuracy() + " m");
    }

    if (location.hasAltitude()) {
        LogHelper.infoLog(TAG, "Changed location has altitude: " + location.getAltitude() + " m");
    }

    if (location.hasBearing()) {
        LogHelper.infoLog(TAG, "Changed location has bearing: " + location.getBearing() + " °");
    }

    if (location.hasSpeed()) {
        LogHelper.infoLog(TAG, "Changed location has speed: " + location.getSpeed() + " m/s");
    }

    Intent intent = new Intent(ACTION_LOCATION_BROADCAST);
    intent.putExtra(EXTRA_PROVIDER, location.getProvider());
    intent.putExtra(EXTRA_LATITUDE, location.getLatitude());
    intent.putExtra(EXTRA_LONGITUDE, location.getLongitude());
    intent.putExtra(EXTRA_TIME, location.getTime());
    intent.putExtra(EXTRA_ELAPSED_REALTIME_NANOS, location.getElapsedRealtimeNanos());
    intent.putExtra(EXTRA_EXTRAS, location.getExtras());
    intent.putExtra(EXTRA_ACCURACY, location.getAccuracy());
    intent.putExtra(EXTRA_ALTITUDE, location.getAltitude());
    intent.putExtra(EXTRA_BEARING, location.getBearing());
    intent.putExtra(EXTRA_SPEED, location.getSpeed());

    LocalBroadcastManager.getInstance(this).sendBroadcast(intent);

    try {
        mRealm.executeTransaction(new Realm.Transaction() {
            @Override
            public void execute(Realm realm) {
                LocationRealmObject locationRealmObject = realm.createObject(LocationRealmObject.class);
                locationRealmObject.setProvider(location.getProvider());
                locationRealmObject.setLatitude(location.getLatitude());
                locationRealmObject.setLongitude(location.getLongitude());
                locationRealmObject.setTime(location.getTime());
                locationRealmObject.setElapsedRealtimeNanos(location.getElapsedRealtimeNanos());
                locationRealmObject.setAccuracy(location.getAccuracy());
                locationRealmObject.setAltitude(location.getAltitude());
                locationRealmObject.setBearing(location.getBearing());
                locationRealmObject.setSpeed(location.getSpeed());
            }
        });
    } catch (Exception e) {
        LogHelper.errorLog(TAG, e.getMessage());
        e.printStackTrace();
    }
}
 
開發者ID:n37bl4d3,項目名稱:Android-Location-Tracker,代碼行數:79,代碼來源:LocationService.java


注:本文中的android.location.Location.hasBearing方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。