FreeDroid开发过程中遇到的一些问题

http://bestzp.com/?p=83

Android Studio混淆:

build.gradle中

 
1
2
3
4
5
6
buildTypes {
        release {
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }

minifEnabled 改为 true;

Android Studio 避免混淆第三方lib:

我这里用的是waps的lib,在proguard-rules.pro文件中加入

 
1
2
3
4
5
-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命令的例子:

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//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信息的方法:

 
 
 
 
 
 

Java

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
StringRequest stringRequest = new StringRequest(Request.Method.GET,hostsUrl,
                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {
                        
                    }
                }, new Response.ErrorListener() {
            @Override
            public void onErrorResponse(VolleyError error) {
                Log.e("TAG", error.getMessage(), error);
            }
        }){
            //设置header信息
            @Override
            public HashMap<String, String> getHeaders() {
                HashMap<String, String> params = new HashMap<String, String>();
                String header="header";
                params.put("header1", header);
                return params;
            }
        };
上一篇:[abc] AtCoder Beginner Contest 132 E.Hopscotch Addict bfs


下一篇:关于如何将汇编语言字符串进行运算(含16进制)