I need to get the Android device timestamp in the format hh:mm:ss:SS. I am able to view the time displayed in the Logcat of Eclipse. Is it the computer's time or is it the Android device's time?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Taken from Reading and Writing Logs on the Developer Site:
"time — Display the date, invocation time, priority/tag, and PID of the process issuing the message."
On the emulator it will be your computers time, on a device it will be time of your device...
If you need the device date programmatically:
If you are running your app on Android device then it will print device's time, if on emulator then it will show computer's time.
To be ensure just match the Log's time with device's time and with computer's time you will find your answer..
use
adb logcat -v threadtime
in terminal to take the logs from device, it will include date and time.if you want to redirect these logs into a text file then use command in terminal.
Use
long
,threadtime
ortime
formats withlogcat -v <format>
logcat
has a number of format options, which can be passed to the-v
flag in the command line. You can view all of the formats in the documentation here.Here are samples of what each option looks like so you can decide which one suits your needs:
brief
Display priority, tag, and PID of the process issuing the message.
long
Display all metadata fields and separate messages with blank lines.
(I like this the best, but I'm a sucker for whitespace.)
process
Display PID only.
raw
Display the raw log message with no other metadata fields.
tag
Display the priority and tag only.
thread
A legacy format that shows priority, PID, and TID of the thread issuing the message.
threadtime
Display the date, invocation time, priority, tag, PID, and TID of the thread issuing the message.
(The docs say this is the default but not true in my case.)
time
Display the date, invocation time, priority, tag, and PID of the process issuing the message.
NOTE: If you're using this in your app to programmatically collect your User's device logs to send to your support team or whatever, you need to omit the space between
-v
and theformat
, like so:Not sure why it's like that but hopefully that saves somebody time trying to figure that out.
From the docs of logcat you can see that there is an option to specify how the output is formatted (-v).
To get a timestamp, you can use the command
This will prefix each message with a timestamp.