當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。