当前位置: 首页>>代码示例>>Java>>正文


Java Location.getExtras方法代码示例

本文整理汇总了Java中android.location.Location.getExtras方法的典型用法代码示例。如果您正苦于以下问题:Java Location.getExtras方法的具体用法?Java Location.getExtras怎么用?Java Location.getExtras使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.location.Location的用法示例。


在下文中一共展示了Location.getExtras方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCurrent

import android.location.Location; //导入方法依赖的package包/类
@Override
public String getCurrent() {
    if (infoCollector != null) {
        String locationString = null;
        final Location loc = infoCollector.getLocationInfo();
        if (loc != null) {
            final int satellites;
            if (loc.getExtras() != null) {
                satellites = loc.getExtras().getInt("satellites");
            } else {
                satellites = 0;
            }

            locationString = Helperfunctions.convertLocationAccuracy(context.getResources(),
                    loc.hasAccuracy(), loc.getAccuracy(), satellites);

            locationString += " (" + Helperfunctions.getAgeString(loc) + ")";
        } else {
            locationString = context.getString(R.string.not_available);
        }

        return locationString;
    }

    return null;
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:27,代码来源:LocationAccuracyDetailsItem.java

示例2: appendData

import android.location.Location; //导入方法依赖的package包/类
/** Add another track point to the GPX file.
 *
 * For more information and examples about the GPX format, see https://de.wikipedia.org/wiki/GPS_Exchange_Format.
 *
 * @param location The data to append as a track point
 */
void appendData(Location location){
    // 1: latitude, 2: longitude, 3: attributes
    final String TRACKPOINT_FORMAT = "\t\t<trkpt lat=\"%1$s\" lon=\"%2$s\">\n%3$s\t\t</trkpt>\n";

    // attributes
    final String ALTITUDE_FORMAT = "\t\t\t<ele>%1$s</ele>\n";
    final String TIME_FORMAT = "\t\t\t<time>%1$s</time>\n";
    final String NUMBER_OF_SAT_FORMAT = "\t\t\t<sat>%1$s</sat>\n";

    SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.getDefault());
    String time = dateFormat.format(location.getTime());

    StringBuilder attributes = new StringBuilder();
    attributes.append(String.format(ALTITUDE_FORMAT, location.getAltitude()));
    attributes.append(String.format(TIME_FORMAT, time));

    Bundle extras = location.getExtras();
    if((extras != null) && (extras.getString("satellites") != null)){
        String numberOfSatellites = extras.getString("satellites");
        attributes.append(String.format(NUMBER_OF_SAT_FORMAT, numberOfSatellites));
    }

    // TODO: include "horizontal dilution of precision" as an attribute
    // TODO: include speed uncertainty as an attribute [NOT IN THE STANDARD!]

    String trackpoint = String.format(TRACKPOINT_FORMAT, location.getLatitude(), location.getLongitude(), attributes);
    file.write(trackpoint);
}
 
开发者ID:renatobellotti,项目名称:FreeRun,代码行数:35,代码来源:GPXGenerator.java


注:本文中的android.location.Location.getExtras方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。