当前位置: 首页>>代码示例>>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;未经允许,请勿转载。