Get the log from android device
2016-08-07 15:54
363 查看
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
[b] Second step : Get the Log to buffer [/b]
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; }
[b] Second step : Get the Log to buffer [/b]
mPrefStore = new PreferenceStore(); mPrefStore.setDefault(LogCatMessageList.MAX_MESSAGES_PREFKEY, LogCatMessageList.MAX_MESSAGES_DEFAULT); mLogcatReceiver= new LogCatReceiver(mdevice, mprefStore);
相关文章推荐
- Unable to get the focused window from device - android
- Unable to get the focused window from device
- How to retrieve the Device Unique ID from android device
- search a file from directory and get storage directorys from android device(i use tablet here)
- 获取显示窗口警告 android The method getWidth() from the type Display is deprecated
- Get Android stack trace from device using Debug Bridge
- HOWTO get multiple value from the same name checkbox elements or radiobution elements
- Adding a device from a kernel module the udev way (pi, a device that prints out the value of pi)
- What Android Can Learn From the iPhone: It’s the Software, Stupid.
- How can I get the next auto increment value from mssql?
- symbian add log and get the correct part
- How to get the text from any standard object
- Get the parameter from the URL
- Using Timer to get history values from EDNA database, an error is prompted in the page : "Sys.WebForms.PageRequestManagerTimeout
- Get the webpage data from URI.
- How to get a notification from Linux when the set of network interfaces changes
- How to get the password text in a text with password property from another process using C++ - 用C++如何从不同进程获取密码框文本
- platform builder was unable to read the device settings from the datastore问题解决
- [导入]Unable to get the project ile from the web server错误的解决方法
- Unable to get the project file from the Web Server(in .NET 2005 IDE)