个人安卓编程遇到难题或者资料的笔记
catroom / catroomandroidnotes Goto Github PK
View Code? Open in Web Editor NEWmy Android and Java Notes
my Android and Java Notes
http://www.lai18.com/content/1513532.html这个文章是没有用的。要webivew接收http的错误码
@OverRide
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
Log.d(LOG_TAG, "onReceivedHttpError: "+errorResponse.getStatusCode()+" "+errorResponse.getReasonPhrase());
super.onReceivedHttpError(view, request, errorResponse);
}
http://charlee.li/android-load-cert-err-ssl-in-webview.html
http://wolfeye.baidu.com/blog/webview-ignore-ssl-error/
https://www.servertastic.com/support/error-111-net-err-tunnel-connection-failed-unknown-error
接收不了ssl的即https的错误码
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {
`public class CarrieroperatorUtils {
private static String LOG_TAG = "carr";
private static String imsi;
/**
* 获取当前sim的运营商信息
*/
public static int getCurrentCarInfo(Context context){
TelephonyManager systemService = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (systemService != null) {
imsi= systemService.getSubscriberId();
if (imsi==null){
Log.v(LOG_TAG,"识别不了插入sim卡");
return ProxyConstant.UNKNOWN_CARRIERPERATOR;
}
}
Log.v(LOG_TAG, "imsi码为 "+imsi);
//三大运营商
if(imsi.contains("46000") || imsi.contains("46002") || imsi.contains("46007")){
Log.v(LOG_TAG,"**移动");
return ProxyConstant.CHINA_MOBILE_CMCC;
}else if(imsi.contains("46001") || imsi.contains("46006")){
Log.v(LOG_TAG,"**联通");
return ProxyConstant.CHINA_UNICOM_CUCC;
}else if(imsi.contains("46003") || imsi.contains("46005") || imsi.contains("46011")){
Log.v(LOG_TAG,"**电信");
return ProxyConstant.CHINA_TELECOM_CTCC;
}else{
Log.v(LOG_TAG,"不支持的该运营商或者识别不了插入sim卡");
return ProxyConstant.UNKNOWN_CARRIERPERATOR;
}
}
/**
* 判断传入的参数号码为哪家运营商
* @param mobile
* @return 运营商名称
*/
public static String validateMobile(String mobile){
String returnString="";
if(mobile==null || mobile.trim().length()!=11){
return "-1"; //mobile参数为空或者手机号码长度不为11,错误!
}
if (mobile.trim().substring(0,3).equals("134")&&mobile.trim().substring(0,4).equals("1349")){
returnString="3";//特殊卫星上网卡
}
if(mobile.trim().substring(0,3).equals("134") || mobile.trim().substring(0,3).equals("135") ||
mobile.trim().substring(0,3).equals("136") || mobile.trim().substring(0,3).equals("137")
|| mobile.trim().substring(0,3).equals("138") || mobile.trim().substring(0,3).equals("139") || mobile.trim().substring(0,3).equals("147") || mobile.trim().substring(0,3).equals("150")
|| mobile.trim().substring(0,3).equals("151") || mobile.trim().substring(0,3).equals("152")
|| mobile.trim().substring(0,3).equals("157") || mobile.trim().substring(0,3).equals("158") || mobile.trim().substring(0,3).equals("159")
|| mobile.trim().substring(0, 3).equals("178") || mobile.trim().substring(0, 3).equals("182") || mobile.trim().substring(0, 3).equals("183") || mobile.trim().substring(0, 3).equals("184")
|| mobile.trim().substring(0,3).equals("187") || mobile.trim().substring(0,3).equals("188")){
returnString="1"; //**移动 19号段
}
if(mobile.trim().substring(0,3).equals("130") || mobile.trim().substring(0,3).equals("131")
|| mobile.trim().substring(0,3).equals("132") || mobile.trim().substring(0,3).equals("145")
|| mobile.trim().substring(0,3).equals("155") || mobile.trim().substring(0,3).equals("156")
|| mobile.trim().substring(0,3).equals("175") || mobile.trim().substring(0,3).equals("176")
|| mobile.trim().substring(0,3).equals("185") || mobile.trim().substring(0,3).equals("186")){
returnString="2"; //**联通 10个号段
}
if(mobile.trim().substring(0,3).equals("133") || mobile.trim().substring(0,3).equals("149")
||mobile.trim().substring(0,3).equals("153") || mobile.trim().substring(0, 3).equals("173")
||mobile.trim().substring(0,3).equals("177") || mobile.trim().substring(0, 3).equals("180")
|| mobile.trim().substring(0,3).equals("181") || mobile.trim().substring(0,3).equals("189")){
returnString="3"; //**电信 9个号段
}
if(returnString.trim().equals("")){
returnString="0"; //未知运营商
}
return returnString;
}
}
`
http的返回码http://w3school.com.cn/tags/html_ref_httpmessages.asp
http://blog.sina.com.cn/s/blog_59b052fa0100it74.html
https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
假如我们定义了537不属于标准(已知的)的http返回码,也会返回response中的537,536等等只要属于5xx
但是假如是https请求会得不到response,要try catch得到io异常里面的错误信息
E/IOException: java.io.IOException: Unexpected response code for CONNECT: 537
我们常常新建了一个project的package name 是com.xxx.application.假如我们想分模块建立子包,在目录模式下面,例如在com.xxx.application.login登录模块后面直接new package 三个model ,view,presenter。必须切换目录模式为android才新建子包。这样看起来就不会login.view.model.presenter在一起。或者关掉 flatten package不是平铺。。
View rootView = ((ViewGroup) (getWindow().getDecorView().findViewById(android.R.id.content))).getChildAt(0);或者ViewGroup content =(ViewGroup)findViewById(android.R.id.content);
Android Studio是用gradle来构建项目的,有很多环境方面的文件都不需要增加到SVN版本库。
以下为列出不需要增加到版本库的文件:
.idea 文件夹,此文件夹是用来保存开发工具的设置信息。
.gradle 文件夹,此文件夹是用来保存gradle的依赖信息。
所有的 build 文件夹,build文件夹是用来保存编译后的文件目录。
所有的 .iml 文件,是用来保存开发工具信息。
local.properties 文件,是用来保存项目依赖信息
下载地址
在文件目录下生成pcap,假如有装wireshark会自动打开。tPacketCapture可以分析不在WiFi网络下的截包。
首先在setting找到sdk location的位置,然后双击tools下面的uiautomatorviewer https://jingyan.baidu.com/article/e4d08ffd8ea80c0fd2f60df1.html
虽然在Android Studio下使用Hierarchy Viewer可以看到,但只是能模拟器
https://developer.android.com/studio/profile/hierarchy-viewer.html
http://blog.csdn.net/lmj623565791/article/details/45556391
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.