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
mPrefStore = new PreferenceStore(); mPrefStore.setDefault(LogCatMessageList.MAX_MESSAGES_PREFKEY,
LogCatMessageList.MAX_MESSAGES_DEFAULT); mLogcatReceiver= new LogCatReceiver(mdevice, mprefStore);
Get the log from android device的更多相关文章
- 在Android Studio中打开Android Device Monitor时报错的解决方法
在Android Studio中打开Android Device Monitor时报以下错误时(Android-SDK\tools\lib\monitor-x86_64\configuration\1 ...
- LED notification in Android device
Code can control the LED notification in Android device, using android.app.Notification: 1 2 3 4 5 6 ...
- Android Device Orientation
最近在处理相机拍照的方向问题,在Android Device的Orientation问题上有了些疑问,就顺便写个Demo了解下Android Device Orientation究竟是怎么个判断. A ...
- 解决Android Device Chooser 找不到设备问题
第一种情况: 已经启动了官方的模拟器也进入了Android手机界面,可是在Android Device Chooser 看不到设备,怎么办? 例如以下图所看到的,使用Reset adb 或者在adb所 ...
- Android Device Chooser中显示Target unknown解决方法
手机插在电脑上准备调试程序来着,通过eclipse运行时,弹出的Android Device Chooser中显示设备名是?????,Target未知,无法继续运行. 可以通过以下步骤解决(Ubunt ...
- 6.5、Android Studio的Android Device Monitor
Android Device Monitor是一个独立的工具,可以对Android应用进行调试和分析.Android Device Monitor无需安装整合在一个IDE中,比如像Android St ...
- Android Device Administration 设备管理器——实现一键锁屏
Android Device Administration 设备管理器--实现一键锁屏 最近研究了一下安全这一块的内容,当然,我是比较水的,所以也拿不出什么好知识点,但是有一些冷门的东西我还是可以聊聊 ...
- Android device debug (adb) by Charge Only mode
Android device debug by Charge Only mode Method 1 Connect devices to computer and execute lsusb Find ...
- 解决 Android Device Monitor 常见问题
Ø 简介 什么是 Android Device Monitor,中文意思就是安卓设备监视器,用于管理安装设备(手机.模拟器)用的.下面列出 Android Device Monitor 常见的一些问 ...
随机推荐
- 1-2+3-4+5-6+7......+n的几种实现
本文的内容本身来自一个名校计算机生的一次面试经历,呵呵,没错,你猜对了,肯定 不是我 个人很喜欢这两道题,可能题目原本不止两道,当然,我这里这分析我很喜欢的两道. 1.写一个函数计算当参数为n(n很大 ...
- MAC的OS X10.10更新以后进入用户界面就死机
我用的是搜狗输入法,所以把搜狗卸载就好了.(注意是卸载,不是单纯的从输入源里移除) 下载一个搜狗输入法的DMG,打开后选择卸载搜狗输入法. 转自: http://zhidao.baidu.com/qu ...
- object-c 系列教程
1.object-c 基本数据类型 2.object-c 控制语句 3.object-c面向对象1 4.object-c面向对象2 5.object-c 继承多态 动态数据类型
- (转)SQL SERVER的锁机制(四)——概述(各种事务隔离级别发生的影响)
六.各种事务隔离级别发生的影响 修改数据的用户会影响同时读取或修改相同数据的其他用户.即这些用户可以并发访问数据.如果数据存储系统没有并发控制,则用户可能会看到以下负面影响: · 未提交的依赖关系(脏 ...
- 【JAVA、C++】LeetCode 020 Valid Parentheses
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the inpu ...
- ubuntu下设置Android手机驱动
如果下面的文章不好使,建议读一这个文章:http://forum.xda-developers.com/xperia-u/general/howto-usb-connection-to-ubuntu- ...
- Machine Schedule(poj 1274)
题目大意:有n个奶牛和m个谷仓,现在每个奶牛有自己喜欢去的谷仓,并且它们只会去自己喜欢的谷仓吃东西,问最多有多少奶牛能够吃到东西 输入第一行给出n与m 接着n行 每行第一个数代表这个奶牛喜欢的谷仓的个 ...
- 食物链(codevs 1074)
题目描述 Description 动物王国中有三类动物 A,B,C,这三类动物的食物链构成了有趣的环形.A吃B,B吃C,C吃A. 现有N个动物,以1-N编号.每个动物都是A,B,C中的一种,但是我们并 ...
- Ajax案例(使用ajax进行加法运算)
此案例功能实现了一边看视频一边进行加法运算,而加法运算时页面不会刷新请求 ajax代码: <script type="text/javascript" src="j ...
- Android实现边缘凹凸的View
转载 最近做项目的时候遇到一个卡劵的效果,由于自己觉得用图片来做的话可以会出现适配效果不好,再加上自己自定义view方面的知识比较薄弱,所以想试试用自定义View来实现.但是由于自己知识点薄弱,一开始 ...