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的更多相关文章

  1. 在Android Studio中打开Android Device Monitor时报错的解决方法

    在Android Studio中打开Android Device Monitor时报以下错误时(Android-SDK\tools\lib\monitor-x86_64\configuration\1 ...

  2. LED notification in Android device

    Code can control the LED notification in Android device, using android.app.Notification: 1 2 3 4 5 6 ...

  3. Android Device Orientation

    最近在处理相机拍照的方向问题,在Android Device的Orientation问题上有了些疑问,就顺便写个Demo了解下Android Device Orientation究竟是怎么个判断. A ...

  4. 解决Android Device Chooser 找不到设备问题

    第一种情况: 已经启动了官方的模拟器也进入了Android手机界面,可是在Android Device Chooser 看不到设备,怎么办? 例如以下图所看到的,使用Reset adb 或者在adb所 ...

  5. Android Device Chooser中显示Target unknown解决方法

    手机插在电脑上准备调试程序来着,通过eclipse运行时,弹出的Android Device Chooser中显示设备名是?????,Target未知,无法继续运行. 可以通过以下步骤解决(Ubunt ...

  6. 6.5、Android Studio的Android Device Monitor

    Android Device Monitor是一个独立的工具,可以对Android应用进行调试和分析.Android Device Monitor无需安装整合在一个IDE中,比如像Android St ...

  7. Android Device Administration 设备管理器——实现一键锁屏

    Android Device Administration 设备管理器--实现一键锁屏 最近研究了一下安全这一块的内容,当然,我是比较水的,所以也拿不出什么好知识点,但是有一些冷门的东西我还是可以聊聊 ...

  8. 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 ...

  9. 解决 Android Device Monitor 常见问题

    Ø  简介 什么是 Android Device Monitor,中文意思就是安卓设备监视器,用于管理安装设备(手机.模拟器)用的.下面列出 Android Device Monitor 常见的一些问 ...

随机推荐

  1. Linux awk命令详解??????????(研究)

    http://blog.chinaunix.net/uid-25120309-id-3801250.html 一.  AWK 说明  awk是一种编程语言,用于在linux/unix下对文本和数据进行 ...

  2. 【SpringMVC】SpringMVC系列12之数据类型转换、格式化、校验

      12.数据类型转换.格式化.校验 12.1.数据绑定流程     Spring MVC 主框架将 ServletRequest 对象及目标方法的入参实例传递给 WebDataBinderFacto ...

  3. Java最常用的变量定义汇总

    Java最常用的数据类型有基本数据类型,字符串对象,数组,基本数据类型又分为:数值型(包括整形和浮点型),字符型,布尔型,下面用一个简单的程序把这些数据类型汇总一下 public class Java ...

  4. Java面向对象的封装

    封装是Java面向对象的三大特性之一,通常我们是通过包管理机制同时对类进行封装,隐藏其内部实现细节,通常开发中不允许直接操作类中的成员属性,所以属性一般设置为私有权限private,类中一般会给出一些 ...

  5. 10件在PHP 7中不要做的事情

    刚刚在园子里看到一篇特别好的文章,就拿到我的园子里分享了. 1. 不要使用mysql_函数 这一天终于来了,从此你不仅仅“不应该”使用mysql_函数.PHP 7 已经把它们从核心中全部移除了,也就是 ...

  6. 配置SecureCRT连接本地虚拟机中的Linux系统

    转自:http://www.pythoner.com/196.html 由于平时公司开发时都是使用SecureCRT连接的Linux服务器,所以也想使用SecureCRT在自己电脑上连接本地虚拟机中的 ...

  7. Fedora 启动sshd服务:

    .先确认是否已安装ssh服务: [root@localhost ~]# rpm -qa | grep openssh-server openssh-server-.3p1-.fc12.i686 (这行 ...

  8. redhad借用CentOs yum 安装

    RedHat linux 默认是安装了yum软件的,但是由于激活认证的原因让redhat无法直接进行yum安装一些软件,如果我们需要在redhat下直接yum安装软件,我们只用把yum的源修改成Cen ...

  9. 今天连续几次被其他电脑客户端踢下线,也不知是否是ip冲突

    可能是利用ip然后我的网络也没有关掉共享,其次就是远程开启了一个叫做"学生端"的应用,好在我改密码连续两次改的快

  10. hdu 4586 Play the Dice 概率推导题

    A - Play the DiceTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/ ...