简体   繁体   中英

LocationUpdates module in Android Studio - How can I include the date with the time and have it update with the coordinates?

Here's the code it currently relies on for updates:

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

I tried this:

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

and that at least printed date and time. However, it doesn't update with coordinates. Any idea how to make it update with coordinates?

Got it.

changed

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

to

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM