1、 打印当前函数调用栈
java.util.Map<Thread, StackTraceElement[]> ts = Thread.getAllStackTraces();
StackTraceElement[] ste = ts.get(Thread.currentThread());for (StackTraceElement s : ste) {
android.util.Slog.e("SS ", s.toString()); //这个是android自带的,如果没有,用其他的打印函数一样
}
2、打印当前使用内存和剩余内存
Log.i("DragLayer", "NativeHeapSizeTotal:"+(android.os.Debug.getNativeHeapSize()) + "bytes");
Log.i("DragLayer", "NativeAllocatedHeapSize:"+(android.os.Debug.getNativeHeapAllocatedSize()) + "bytes");Log.i("DragLayer", "NativeAllocatedFree:"+(android.os.Debug.getNativeHeapFreeSize()) + "bytes");
3、打印手机屏幕分辨率
DisplayMetrics dm = new DisplayMetrics();getWindowManager().getDefaultDisplay().getMetrics(dm);
Log.i("Launcher--------", "--------------width = " + dm.widthPixels + "----height = " + dm.heightPixels);
4、打印android系统中单个应用使用内存上限
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);Log.i("LaucnherApplication", "before----------------------------------------mem up limit = " + activityManager.getMemoryClass());
5、屏幕截图
adb shell /system/bin/screencap -p /sdcard/screenshot.png
adb pull /sdcard/screenshot.png d:/screenshot.png