https://blog.csdn.net/leizhiheng320/article/details/79410088
作者:root
Android File Descriptor(文件描述符)
抱歉,Xposed真的可以为所欲为
发丘摸金,搬山卸岭,跨进程传输大数据
Android TransactionTooLargeException 解析,思考与监控方案
Android获取Root权限和执行Shell脚本
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class ShellUtil {
/**
* 获取Root权限
*
* @return
*/
public static boolean getRoot() {
boolean res = false;
try {
Process process = Runtime.getRuntime().exec("su -c exit");
int exitValue = process.waitFor();
if (exitValue == 0) {
res = true;
}
exitProcess(process);
} catch (Exception e) {
e.printStackTrace();
}
return res;
}
/**
* 执行Shell命令(必须有Root权限)
*
* @param cmd
*/
public static String execShell(String cmd) {
StringBuffer sb = new StringBuffer();
try {
Process process = Runtime.getRuntime().exec("su -c " + cmd);
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
String line;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
reader.close();
exitProcess(process);
} catch (IOException e) {
e.printStackTrace();
}
return sb.toString();
}
/**
* 获取FD数量
*
* @return
*/
public static int getFDNumber() {
int res = 0;
try {
int pid = android.os.Process.myPid();
Process process = Runtime.getRuntime().exec("ls /proc/" + pid + "/fd");
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
while (reader.readLine() != null) {
res++;
}
reader.close();
exitProcess(process);
} catch (IOException e) {
e.printStackTrace();
}
return res;
}
/**
* 退出进程
*
* @param process
*/
private static void exitProcess(Process process) {
try {
if (process != null) {
process.exitValue();
}
} catch (IllegalThreadStateException e) {
process.destroy();
}
}
}
Android查看密钥和APK签名
查看密钥签名:
keytool -list -v -keystore 目标文件路径(debug.keystore)
查看APK签名:
keytool -printcert -file 目标文件路径(CERT.RSA)
Android logcat 后台运行
后台运行:
adb logcat -v time -n 100 -r 10240 -f /sdcard/Logs/log &
查看进程:
ps logcat
参考链接:
Android源码在线查看
【转】Android退到后台与切到前台
转载自:Android退到后台与切到前台
最近开发了一款TV版app,主要功能是视频通话,所以要求机顶盒是一开机,就要把app打开,因为时刻有别人打过来。然后点击返回按钮,需要把app切到后台,但是app仍需要存活,需要收到消息。所以这里就设计到了app退到后台与切到前台的功能。
app退到后台
1.一般情况下,是启动Home页就可以实现这个功能,代码如下
Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_HOME); startActivity(intent);
这里需要注意的是,如果Launcher和Home不是同一个,那就不能这么用。比如说华数机顶盒Launcher,启动第三方app都是从这里打开的。然后这里如果执行了上述代码,启动了Home,那就跳转到了Android系统的Home,与退到后台的效果有所出入了。
2.执行Activity#moveTaskToBack()
moveTaskToBack(false);