简体   繁体   English

如何在用户的Android设备上读取日志和设备信息?

[英]How to read logs and device info on users' android device?

The scenario is (should happen to every app): Someone installed your apk and but sometimes the app crashed. 场景是(应该发生在每个应用程序上):有人安装了apk,但有时该应用程序崩溃了。 You want the user to send back the logs and device info (vendor, model, os, sdk etc). 您希望用户发回日志和设备信息(供应商,型号,操作系统,SDK等)。 You have such an menu item "report bug". 您具有这样的菜单项“报告错误”。

Is there such an example to implement it (in Java)? 有没有实现它的示例(在Java中)? Thanks. 谢谢。

java.lang.Thread.UncaughtExceptionHandler java.lang.Thread.UncaughtExceptionHandler

  1. new a class implements UncaughtExceptionHandler 新的类实现了UncaughtExceptionHandler
  2. in your application set this UncaughtExceptionHandler (eg. onCreate() Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandlereh)) 在您的应用程序中设置此UncaughtExceptionHandler(例如,onCreate()Thread.setDefaultUncaughtExceptionHandler(UncaughtExceptionHandlereh))
  3. you can do your work in method uncaughtException(final Thread thread, final Throwable ex) 你可以在方法uncaughtException(final thread thread,final Throwable ex)中完成工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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