Android Studio 中的 LocationUpdates 模块 - 如何包含日期和时间并使其更新坐标?



这是它目前依赖更新的代码:

mLastUpdateTimeTextView.setText(String.format(Locale.ENGLISH, "%s: %s",
mLastUpdateTimeLabel, mLastUpdateTime));

我试过这个:

SimpleDateFormat sdf = new SimpleDateFormat("MM-dd-yyyy HH:mm:ss", Locale.getDefault());
String currentDateandTime = sdf.format(new Date());
mLastUpdateTimeTextView.setText("Date/Time:"+ " " + currentDateandTime);

并且至少打印了日期和时间。但是,它不会随坐标更新。知道如何用坐标更新它吗?

知道了。

改变

mLastUpdateTime = DateFormat.getTimeInstance().format(new Date());

mLastUpdateTime = DateFormat.getDateTimeInstance().format(new Date());

最新更新