Android 借助Stetho在Chrome上调试Android网络、数据库、Sharedpreferences
Android 借助Stetho在Chrome上调试Android网络、数据库、Sharedpreferences
转载请标明出处:http://blog.csdn.net/zhaoyanjun6/article/details/61919840
本文出自【赵彦军的博客】
简介
Stetho是Facebook开源的Andorid调试工具。当你的应用集成Stetho时,开发者可以访问Chrome,在Chrome Developer Tools中查看应用布局,网络请求,sqlite,preference等等,可视化一切应用操作(更重要的是不用root)。
官网: http://facebook.github.io/stetho/
如何集成
- 在
build.gradle添加
dependencies {
compile 'com.facebook.stetho:stetho-okhttp3:1.4.2'
}
- 初始化
package com.zyj.stetho;
import android.app.Application;
import com.facebook.stetho.Stetho;
/**
* Created by ${zhaoyanjun} on 2017/3/13.
*/
public class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Stetho.initializeWithDefaults(this);
}
}
- 用数据线把手机和电脑连起来,运行App , 打开
Chrome输入chrome://inspect/#devices。可以看到下面的界面。
chrome调试Android 数据库、SharedPreferences
点击inspect将会看到如下Developer Tools界面,如果这个界面出不来,看看是否需要翻墙,你懂得:
点击数据库的表,可以看到数据库里面的数据内容:
点击SharedPreferences可以看到:
查看网络请求
- 首选基于
OkHttp3.x添加拦截器
void net(){
String url = "https://www.baidu.com/" ;
OkHttpClient client = new OkHttpClient.Builder()
.addNetworkInterceptor( new StethoInterceptor()) //添加拦截器
.build() ;
Request request = new Request.Builder()
.url(url)
.build();
Response response = null;
try {
response = client.newCall(request).execute();
if ( response.isSuccessful() ) {
String result = response.body().string() ;
Log.e( "zhao", "net: " + result );
}
} catch (IOException e) {
e.printStackTrace();
}
}
总结:
本例子中的数据库用的是:
lite-orm-1.9.2,jar
地址是:https://github.com/litesuits/android-lite-orm
博客地址:http://www.cnblogs.com/zhaoyanjun/p/5640788.html本例字中使用的网络请求框架为:
okhttp
地址:https://github.com/square/okhttp这个文章所有的代码以上传至Github:https://github.com/zyj1609wz/Stetho
Android 借助Stetho在Chrome上调试Android网络、数据库、Sharedpreferences的更多相关文章
- 通过Stetho在Chrome上调试Android App
引 入依赖包 compile 'com.facebook.stetho:stetho:1.3.1' 初始化一下 public class MyApplication extends Applicati ...
- 如何通过Chrome远程调试android设备上的Web网站
网上的帖子很多,但很多都是老版本的,试过了,根本不管用,花了一天时间,终于在本机试验通过了,特记录下来,以备用.有需要的朋友也可以参考.先上一张图,看看PC端chrome上调试的效果: 左边是手机的模 ...
- android:如何通过chrome远程调试APP中的webView的h5代码
今天出现一个问题,在老板的Mate9 Pro上,我们APP的所有H5页面都是一片空白,但是在其他手机上都是好的,那么我们就怀疑是h5报错了,但是到底是什么错,无法得知,所以就想要可以像在pc的chro ...
- 在 Chrome 中调试 Android 浏览器
最近需要使用 Chrome Developer Tools 调试 Android 浏览器,但是官方指南并不是很好使,经过一番折腾,终于调试成功了,在此把经验分享给需要的朋友. Chrome Devel ...
- 移动端Chrome Inspect调试 (Android通过Chrome Inspect调试WebView的H5)(ios手机safari,chrome调试 windows)(如果inspect的时候,是空白)
ios +chrome调试 引用https://segmentfault.com/a/1190000015428430 iTunes ios-webkit-debug-proxy-1.8-win64- ...
- 在桌面chrome中调试android设备中的web页面
准备工作 1, 桌面版chrome 2, Android设备(安装有chrome浏览器) 3, Android-sdk Android-sdk安装及设置 SKD安装 从http://developer ...
- 使用 桌面的 chrome 远程调试 Android 的页面
手机浏览器是没有开发者工具的,所以调试手机网页是非常麻烦.使用 chrome 的远程调试功能可以像调试桌面端那样调试手机页面. 准备 手机端:chrome for Android, 安装谷歌浏览器 桌 ...
- Chrome浏览器调试Android的Webview
chrome://inspect Android:4.4+ Chrome 30+ 首次使用需要FQ
- Chrome远程调试Android上Chrome的页面
下载最新的google chrome canary 手机chrome开启usb网页调试,如图所示: 在终端运行 ? SHELL adb forward tcp:9222 localabstract:c ...
随机推荐
- 一个对眼睛很好的vim 颜色主题
地址:https://github.com/altercation/vim-colors-solarized 安装: $ cd vim-colors-solarized/colors $ mv sol ...
- apt 下载安装包
1) Try both without sudo, apt-get download will pass and apt-get -d install will fail (root required ...
- SpringSecurity学习之基于数据库的用户认证
SpringSecurity给我们提供了一套最基本的认证方式,可是这种方式远远不能满足大多数系统的需求.不过好在SpringSecurity给我们预留了许多可扩展的接口给我们,我们可以基于这些接口实现 ...
- 持续集成 TeamCity 的配置与使用
环境:实现自动编译与自动化测试,发布到远程服务器,环境 VS2015 +WIN2008R2 什么是TeamCity TeamCity是由Jetbrains开发的一款功能强大的持续集成(Continue ...
- Java 并发优化
线程不安全 SimpleDateFormat不是线程安全的 SimpleDateThread import java.text.ParseException; import java.text.Sim ...
- Apache本地配置虚拟域名
转载+修改 例:虚拟域名为 aaa.com 端口为默认80 index.html所在目录 D:/wamp/www/web 不用解析域名,使用虚假的域名也可以 apache安装完默认是不开启虚拟服务器 ...
- C++ 运算符的重载
#include <iostream> #include <stdio.h> using namespace std; class Complex //复数类 { public ...
- B+树原理及mysql的索引分析
转自:http://blog.csdn.net/qq_23217629/article/details/52512041 B+/-Tree原理 B-Tree介绍 B-Tree是一种多路搜索树(并不是二 ...
- POJ 1730 Perfect Pth Powers(暴力枚举)
题目链接: https://cn.vjudge.net/problem/POJ-1730 题目描述: We say that x is a perfect square if, for some in ...
- 从Spring-Session源码看Session机制的实现细节
Re:从零开始的Spring Session(一) Re:从零开始的Spring Session(二) Re:从零开始的Spring Session(三) 去年我曾经写过几篇和 Spring Sess ...