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


Java Location.convert方法代码示例

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


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

示例1: createMockLocation

import android.location.Location; //导入方法依赖的package包/类
private Location createMockLocation() {
    String longitudeString = longitudeInput.getText().toString();
    String latitudeString = latitudeInput.getText().toString();

    if (!longitudeString.isEmpty() && !latitudeString.isEmpty()) {
        double longitude = Location.convert(longitudeString);
        double latitude = Location.convert(latitudeString);

        Location mockLocation = new Location("flp");
        mockLocation.setLatitude(latitude);
        mockLocation.setLongitude(longitude);
        mockLocation.setAccuracy(1.0f);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
            mockLocation.setElapsedRealtimeNanos(SystemClock.elapsedRealtimeNanos());
        }
        mockLocation.setTime(new Date().getTime());
        return mockLocation;
    } else {
        throw new IllegalArgumentException();
    }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:MockLocationsActivity.java

示例2: convert

import android.location.Location; //导入方法依赖的package包/类
private String convert(double latitude, double longitude) {
    StringBuilder builder = new StringBuilder();


    String latitudeDegrees = Location.convert(Math.abs(latitude), Location.FORMAT_SECONDS);
    String[] latitudeSplit = latitudeDegrees.split(":");
    builder.append(latitudeSplit[0]);
    builder.append("°");
    builder.append(latitudeSplit[1]);
    builder.append("'");
    builder.append(latitudeSplit[2]);
    builder.append("\"");
    if (latitude < 0) {
        builder.append(" S");
    } else {
        builder.append(" N");
    }
    builder.append("\n");


    String longitudeDegrees = Location.convert(Math.abs(longitude), Location.FORMAT_SECONDS);
    String[] longitudeSplit = longitudeDegrees.split(":");
    builder.append(longitudeSplit[0]);
    builder.append("°");
    builder.append(longitudeSplit[1]);
    builder.append("'");
    builder.append(longitudeSplit[2]);
    builder.append("\"");
    if (longitude < 0) {
        builder.append(" W");
    } else {
        builder.append(" E");
    }
    return builder.toString();
}
 
开发者ID:rahul051296,项目名称:quake-alert-android-app,代码行数:36,代码来源:QuakeDetailsActivity.java

示例3: convertLocation

import android.location.Location; //导入方法依赖的package包/类
public static String convertLocation(final Resources res, final double coordinate, final boolean latitude)
{
    final String rawStr = Location.convert(coordinate, Location.FORMAT_MINUTES);
    //[+-]DDD:MM.MMMMM - FORMAT_MINUTES
    final String[] split = rawStr.split(":");
    final String direction;
    float min = 0f;


    //noinspection EmptyCatchBlock
    try
    {
        split[1] = split[1].replace(",",".");
        min = Float.parseFloat(split[1]);
    }
    catch (NumberFormatException e)
    {
    }
    
    if (latitude)
    {
        if (coordinate >= 0)
            direction = res.getString(R.string.test_location_dir_n);
        else
            direction = res.getString(R.string.test_location_dir_s);
    }
    else if (coordinate >= 0)
        direction = res.getString(R.string.test_location_dir_e);
    else
        direction = res.getString(R.string.test_location_dir_w);
    return String.format("%s %s°%.3f'", direction, split[0].replace("-", ""), min);
}
 
开发者ID:rtr-nettest,项目名称:open-rmbt,代码行数:33,代码来源:Helperfunctions.java


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