zoukankan      html  css  js  c++  java
  • Get the log from android device

    Theme:  

        How to get the log from device ?

         Detail:  Get the log from device, and write to the local file .

    Google Source jar:

           Use the methods in ddmlib.jar mostly:  

           import com.android.ddmlib.AndroidDebugBridge;
          import com.android.ddmlib.AndroidDebugBridge.IDeviceChangeListener;
          import com.android.ddmlib.IDevice;

     

    The concrete process:     

        First step :   connect the devices through ADB                            

        //import package
        import com.android.ddmlib.AndroidDebugBridge;
        import com.android.ddmlib.IDevice;
    
        //Creat  AndroidDebugBridge 和 device class object
        private AndroidDebugBridge mBridge;
        private IDevice mDevice;
    
        //Get the device object you want connect
        String serial_number = "INV121501088";
        mBridge = AndroidDebugBridge.createBridge(location, true );
        mdevice = findAttachedDevice(deviceIdRegex);
       
        //Find the device from the devices through AndroidDebugBridge
        private IDevice findAttachedDevice(String deviceIdRegex) {
            Pattern pattern = Pattern.compile(deviceIdRegex);
            for (IDevice device : mBridge.getDevices()) {
                String serialNumber = device.getSerialNumber();
                if (pattern.matcher(serialNumber).matches()) {
                    return device;
                }
            }
            return null;
        }
    
     

                  Second step :   Get the Log to buffer    

    1  mPrefStore = new PreferenceStore();
    2 
    3  mPrefStore.setDefault(LogCatMessageList.MAX_MESSAGES_PREFKEY,
    4                 LogCatMessageList.MAX_MESSAGES_DEFAULT);
    5 
    6  mLogcatReceiver= new LogCatReceiver(mdevice, mprefStore);

            

  • 相关阅读:
    CheckBox单选功能
    DOTNET
    常用命令行
    不能调试的问题的解决
    url字符串中含有中文的处理
    案例:星移eWorkflow.net系统
    使用正则表达式求完整路径中的文件名
    缺少一个***.resource的报告的解决
    Mapx中的图元移动
    Distance计算的距离随经纬度不同
  • 原文地址:https://www.cnblogs.com/udld/p/4569563.html
Copyright © 2011-2022 走看看