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. SPFA算法心得

    SPFA算法是改进后的Bellman-Ford算法,只是速度更快,而且作为一个算法,它更容易理解和编写,甚至比Dijkstra和B-F更易读(当然,Floyd是另一回事了,再也没有比Floyd还好写的 ...

  2. snoopy 强大的PHP采集类使用实例代码

    下载地址: http://www.jb51.net/codes/33397.html Snoopy的一些特点: 1抓取网页的内容 fetch 2 抓取网页的文本内容 (去除HTML标签) fetcht ...

  3. Android PullToRefreshListView上拉刷新和下拉刷新

    PullToRefreshListView实现上拉和下拉刷新有两个步骤: 1.设置刷新方式 pullToRefreshView.setMode(PullToRefreshBase.Mode.BOTH) ...

  4. iOS7 中的statusbar的隐藏和样式更改

    ios7以前,如果想要隐藏statusbar,需要用到[UIApplicationsharedApplication].statusBarHidden = YES; 或者在plist文件中设定Stat ...

  5. canva实践小实例 —— 马赛克效果

    前面给大家带来了操作像素的API,此时此刻,我觉得应该配以小实例来进行进一步的说明和演示,以便给大家带来更宽广的视野和灵感,你们看了我的那么多的文章,应该是懂我的风格,废话不多说,进入正题: 这次给大 ...

  6. Ubuntu12.04安装ia32-libs

    sudo apt-get install libc6:i386 sudo -i cd /etc/apt/sources.list.d// care for old-releases.ubuntu.co ...

  7. glGetFloatv (GL_MODELVIEW_MATRIX, mat)

    这个函数的作用是取出GL_MODELVIEW_MATRIX,然后存储在mat这个矩阵中,用于逆变换等.

  8. 用java程序打印菱形

    代码如下

  9. Nginx(PHP/fastcgi)的PATH_INFO问题

    引用: http://www.laruence.com/2009/11/13/1138.html server { listen 80; server_name localhost; index in ...

  10. sql:除非另外还指定了 TOP 或 FOR XML,否则,ORDER BY 子句在视图、内联函数、派生表、子查询

    执行sql语句: select * from ( select * from tab where ID>20 order by userID desc ) as a order by date ...