如何在应用启动时从ActivityManager获取Activity等待时间?

huangapple go评论64阅读模式
英文:

How to get Activity Waiting Time from ActivityManager on app launching?

问题

我使用ADB来在启动应用程序时显示等待时间活动,我使用的命令是:adb shell am start -S -W com.example.app/.MainActicity -c android.intent.category.LAUNCHER -a android.intent.action.MAIN
这是结果:

如何在应用启动时从ActivityManager获取Activity等待时间?

所以,我的问题是如何以编程方式获取waitTime的值?谢谢。

英文:

I'm using ADB to show Waiting Time Activity on launching app, the command I used is : adb shell am start -S -W com.example.app/.MainActicity -c android.intent.category.LAUNCHER -a android.intent.action.MAIN
here's the result :

如何在应用启动时从ActivityManager获取Activity等待时间?

So, my question is how to get programmatically the waitTime value ? thanks.

答案1

得分: 1

根据评论部分的建议,在拥有基于Linux的终端时,您可以通过解析am start命令的输出并过滤值来以编程方式检索WaitTime,如下所示:

adb shell am start -S -W "com.example.abder.emarque/.Activities.EMarque" -c android.intent.category.LAUNCHER
-a android.intent.action.MAIN | grep -i waittime | cut -d' ' -f2

其中,grep -i waittime 过滤包含 waittime 的行,而 cut 命令检索值本身。

希望这有所帮助。

英文:

As suggested in the comments sections, having a Linux-based terminal you can retrieve the WaitTime programmatically by parsing the output of the the am start command and filtering the value like this:

adb shell am start -S -W "com.example.abder.emarque/.Activities.EMarque" -c android.intent.category.LAUNCHER 
-a android.intent.action.MAIN | grep -i waittime | cut -d' ' -f2

3813

whereas grep -i waittime filters the line containing the waittime and the cut command retrieves the value itself.

Hope this helps.

huangapple
  • 本文由 发表于 2020年1月4日 01:32:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/59582868.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定