做一下记录:
find /sdcard/log/crash/ -mtime +30 | xargs rm -rf
……继续阅读 »
7年前 (2017-08-10) 2387浏览 0评论
0个赞
private YuvImage i420ToYuvImage(ByteBuffer[] yuvPlanes, int[] yuvStrides, int width, int height) {
if (yuvStrides[0] != width) {
return fastI420ToYuvImage(yuvPlanes, yuvStrides, width, height);
}
if (yuvStrides[1] != width / 2) {
return fastI420ToYuvImage(yuvPlanes, yuvSt……继续阅读 »
7年前 (2017-07-13) 2375浏览 0评论
0个赞
pm dump【包名】| grep -A 1 android.intent.action.MAIN: | tail -1
PS:windows貌似不能使用tail
……继续阅读 »
7年前 (2017-07-03) 2394浏览 0评论
1个赞
/**
* 通过包名获取task id,不存在为-1
*
* @param packageName
* @return
*/
public int getTaskId(String packageName) {
String result = execRootCmd("dumpsys activity | grep " + packageName);
int start = result.indexOf("TaskRecord{");
if(start > 0){
int end = result……继续阅读 »
7年前 (2017-07-03) 3379浏览 0评论
0个赞
/**
* 返回当前的应用是否处于前台显示状态
*
* @param packageName
* @return
*/
public boolean isTopActivity(String packageName) {
String result = execRootCmd("dumpsys activity | grep \"mResumedActivity\"");
int start = result.indexOf("u0") + 3;
int end = result.indexOf("/");
Log.d(TAG, "s: " + sta……继续阅读 »
7年前 (2017-06-02) 2784浏览 0评论
3个赞
public boolean isNumeric(String str) {
for (int i = 0; i < str.length(); i++) {
if (!Character.isDigit(str.charAt(i))) {
return false;
}
}
return true;
}
……继续阅读 »
7年前 (2017-06-02) 2365浏览 0评论
0个赞
这里使用的是ps命令,不用root或系统权限。
public int getPid(String name) {
String cmd = ("ps | grep " + name);
String str = execRootCmd(cmd);
if (str == null || str == "" || str.length() < 1)
return -1;
else {
String[] arr = str.split("\\s+");
……继续阅读 »
7年前 (2017-06-02) 3342浏览 0评论
5个赞
// 执行命令并且输出结果
private String execRootCmd(String cmd) {
Log.d(TAG, "cmd: " + cmd);
String result = "";
DataOutputStream dos = null;
DataInputStream dis = null;
try {
Process p = Runtime.getRuntime().exec("su");// 经过Root处理的android系统即有su命令
……继续阅读 »
7年前 (2017-06-02) 2480浏览 0评论
2个赞
效果图如下:
package com.wangsu.tplibrary.ui;
import android.content.Context;
import android.graphics.PixelFormat;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.Windo……继续阅读 »
7年前 (2017-05-21) 2915浏览 2评论
0个赞
Weight 值是一个数字,用于指定每个视图与其他同级视图在剩余空间中的占比。 这有点像饮料配方中各种成分的比例: “2 份苏打、1 份糖浆”是指饮料中三分之二是苏打。例如,如果您将一个视图的 weight 值指定为 2,将另一个视图的 weight 值指定为 1,总和是 3,那么第一个视图将填满剩余空间的 2/3,而第二个视图则填满其余部分。 如果您添加了第三个视图,将其 weight 值指定为 1,那么现在第一个视图(weight 值为 2)将获得 1/2 的剩余空间,其余两个视图则各占 1/4。
所有视图的默认 weight 值都为 0,所以如果您仅将一个视图的 weight 值指定为大……继续阅读 »
7年前 (2017-04-25) 3197浏览 3评论
1个赞