android获得控制台log,打印控制台log
16lz
2021-01-24
//android手机root,然后打印控制台的log,从控制台log中查找 Finsky的信息过滤,然后找到包名信息。
文章出处:https://blog.csdn.net/pangzaifei/article/details/70213731 public static void monitorGooglePlayLogInRoot() { new Thread(new Runnable() { @Override public void run() { Process process = null; DataOutputStream os = null; try { // Finsky为google play log输出过滤标签 String cmd = "logcat -s Finsky"; // 先切换到root进程 process = Runtime.getRuntime().exec("su"); os = new DataOutputStream(process.getOutputStream()); os.writeBytes(cmd + "\n"); os.flush(); BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream())); String line = null; while ((line = bufferedReader.readLine()) != null) { if (line.contains("Selecting account") || line.contains("for package")) { String[] split = line.split("for package "); if (split.length == 2) { String logPart = split[1]; String pkName = logPart.substring(0, logPart.lastIndexOf('.')); Log.e("fffpzf", "google play 打开了详情页,包名为:" + pkName); // 执行下载逻辑// onEnterDetailPage(pkName); } } } } catch (Exception ignored) { } finally { try { if (os != null) { os.close(); } process.destroy(); } catch (Exception e) { } } } }).start(); }
更多相关文章
- Android列表组件ListView使用详解之数据为空提示信息
- android 向数据库写入图片信息 读取图片信息
- Android入门:Log介绍
- android -------- 获取手机设备信息
- Android开发问题汇总
- DownloadManager 文件下载
- Android(安卓)获取通讯录联系人,打开通讯录获取联系人信息;整个流
- Android---58---初学GPS定位
- Android获取手机当前连接的WiFi信息(SSID,IP,连接状态)