我試圖在「onLocationChanged」方法中獲取時間戳,但沒有成功。如何在「onLocationChanged」方法中藉助location.getTime設置時間戳?經度和緯度正在顯示。在onLocationChanged方法中設置時間戳
public void onLocationChanged(Location location) {
\t \t \t // TODO Auto-generated method stub
\t \t \t if (location != null) {
\t \t \t \t double plong = location.getLongitude();
\t \t \t \t double pLat = location.getLatitude();
\t \t \t Date d = new Date();
\t \t \t SimpleDateFormat sdf = new SimpleDateFormat("dd.mm.yyyy hh:mm:ss");
\t \t \t String s = sdf.format(d);
\t \t \t textTime.setText(s);
\t \t \t \t textLat.setText(Double.toString(pLat));
\t \t \t \t textLong.setText(Double.toString(plong));
\t \t \t }
\t \t }
我不知道是否Android的時間戳工作,它已被棄用。你有沒有嘗試日期而不是 – faljbour 2015-04-05 16:35:04
看到這篇文章,http://stackoverflow.com/questions/16579921/android-locatoin-gettime-always-returns-big-different-time – faljbour 2015-04-05 16:48:59