标签:
Android Studio混淆:
build.gradle中
123456 buildTypes {release {minifyEnabled trueproguardFiles getDefaultProguardFile(‘proguard-android.txt‘), ‘proguard-rules.pro‘}}minifEnabled 改为 true;
Android Studio 避免混淆第三方lib:
我这里用的是waps的lib,在proguard-rules.pro文件中加入
12345 -dontwarn android.support.**-keep public class cn.waps.** {*;}-keep public interface cn.waps.** {*;}-dontwarn cn.waps.**-ignorewarnings
Drawer的箭头指示器:
使用ToolBar代替ActionBar,添加support-v7的ActionBarDrawerToggle即可。
Drawer覆盖ToolBar:
将ToolBar放入DrawerLayout的第一个子View中即可
获取Root权限并以Root身份执行linux命令的例子:
12345678910111213141516171819202122232425262728 //su权限try {process= Runtime.getRuntime().exec("su");os=new DataOutputStream(process.getOutputStream());is=new DataInputStream(process.getInputStream());os.writeBytes("mount -o remount -o rw /system"+ " \n");//>为覆盖,>>为追加os.writeBytes("echo ‘"+response+"‘ > /etc/hosts" + " \n");os.writeBytes(" exit \n");os.flush();InputStreamReader reader=new InputStreamReader(is);StringBuilder builder=new StringBuilder();int ch;while ((ch=reader.read())!=-1){builder.append((char)ch);System.out.print((char)ch);}Log.i("RES",builder.toString());mListener.onComplete();button.setProgress(100);process.waitFor();} catch (IOException e) {e.printStackTrace();} catch (InterruptedException e) {e.printStackTrace();}
Voelly添加Header信息的方法:
123456789101112131415161718192021 StringRequest stringRequest = new StringRequest(Request.Method.GET,hostsUrl,new Response.Listener<String>() {@Overridepublic void onResponse(String response) {}}, new Response.ErrorListener() {@Overridepublic void onErrorResponse(VolleyError error) {Log.e("TAG", error.getMessage(), error);}}){//设置header信息@Overridepublic HashMap<String, String> getHeaders() {HashMap<String, String> params = new HashMap<String, String>();String header="header";params.put("header1", header);return params;}};
标签:
原文地址:http://www.cnblogs.com/csonezp/p/4232820.html