Get the log from Android device

Source: Internet
Author: User

Theme:

    How do I 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    ImportCom.android.ddmlib.AndroidDebugBridge; ImportCom.android.ddmlib.IDevice; //creat Androiddebugbridge and Device class object    PrivateAndroiddebugbridge Mbridge; PrivateIDevice Mdevice; //Get The device object you want connectString serial_number = "INV121501088"; Mbridge= Androiddebugbridge.createbridge (Location,true ); Mdevice=Findattacheddevice (Deviceidregex); //Find the device from the devices through Androiddebugbridge    PrivateIDevice Findattacheddevice (String deviceidregex) {pattern pattern=Pattern.compile (Deviceidregex);  for(IDevice device:mBridge.getDevices ()) {String serialnumber=Device.getserialnumber (); if(Pattern.matcher (serialnumber). Matches ()) {returndevice; }        }        return NULL; } 

Second Step:get The Log to buffer   

1  New Preferencestore (); 2 3 Mprefstore.setdefault (Logcatmessagelist.max_messages_prefkey,4                Logcatmessagelist.max _messages_default); 5 6  New Logcatreceiver (Mdevice, Mprefstore);

Get the log from Android device

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.