Android环境配置完了之后,需要把adb这个方法所在目录加入到环境变量中:
可选的三种方法如下:
1.通过export:
export PATH=$PATH:/home/xiaoyaomeng/software/android-sdk-linux/platform-tools
2.修改profile文件:
sudo gedit /etc/profile加入: export PATH="$PATH:/home/xiaoyaomeng/software/android-sdk-linux/platform-tools"
3. 修改.bashrc文件:
sudo gedit /root/.bashrc
加入:export PATH="$PATH:/home/xiaoyaomeng/software/android-sdk-linux/platform-tools"
三种写法看起来都是保存原来的PATH,然后往后加新的路径进来,之间用 :(冒号) 隔开
logcat是android系统中的一个命令,是一个可执行的bin文件,放置在/system/bin目录下。
root@android:/system/bin # ls -l logcat -rwxr-xr-x root shell 13680 2008-08-01 12:00 logcat
logcat的源代码在/system/core下面,根据Android.mk:
# Copyright 2006 The Android Open Source Project LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_SRC_FILES:= logcat.cpp event.logtags LOCAL_SHARED_LIBRARIES := liblog LOCAL_MODULE:= logcat include $(BUILD_EXECUTABLE
可以看出编译出来是可执行文件。
要是感兴趣可以研究一下。
看一下logcat的注释:
Usage: logcat [options] [filterspecs] options include: -s Set default filter to silent. Like specifying filterspec '*:s' -f <filename> Log to file. Default to stdout -r [<kbytes>] Rotate log every kbytes. (16 if unspecified). Requires -f -n <count> Sets max number of rotated logs to <count>, default 4 -v <format> Sets the log print format, where <format> is one of: brief process tag thread raw time threadtime long -c clear (flush) the entire log and exit -d dump the log and then exit (don't block) -t <count> print only the most recent <count> lines (implies -d) -g get the size of the log's ring buffer and exit -b <buffer> Request alternate ring buffer, 'main', 'system', 'radio' or 'events'. Multiple -b parameters are allowed and the results are interleaved. The default is -b main -b system. -B output the log in binary filterspecs are a series of <tag>[:priority] where <tag> is a log component tag (or * for all) and priority is: V Verbose D Debug I Info W Warn E Error F Fatal S Silent (supress all output) '*' means '*:d' and <tag> by itself means <tag>:v If not specified on the commandline, filterspec is set from ANDROID_LOG_TAGS. If no filterspec is found, filter defaults to '*:I' If not specified with -v, format is set from ANDROID_PRINTF_LOG or defaults to "brief"
解释一下options:
-s 相当于一个过滤器
-f <filename> 输出到文件,默认情况是标准输出.
-r [<kbytes>] 循环log的字节数(默认为16),需要-f.
-n <count> 设置循环log的最大数目,默认是4
-v <format> 设置log的打印格式, <format> 是下面的一种: brief process tag thread raw time threadtime long.
-c 清除所有log并退出.
-d 得到所有log并退出 (不阻塞).
-g 得到环形缓冲区的大小并退出.
-b <buffer> 请求不同的环形缓冲区('main' (默认), 'radio', 'events').
-B 输出log到二进制中.
解释一下优先级:
filterspecs are a series of <tag>[:priority]
where <tag> is a log component tag (or * for all) and priority is: //这个tag可以是用户定义的,或者是用*代表所有tag,而优先级是V D I W E F S,等级越来越高
V Verbose
D Debug
I Info
W Warn
E Error
F Fatal
S Silent (supress all output)
例如:adb logcat ActivityManager:I MyApp:D *:S 或者 adb logcat -s ActivityManager:I MyApp:D
上面表达式的最后的元素 *:S ,,是设置所有的标签为”silent”,所有日志只显示有”ActivityManager”和“MyApp”的,用 *:S 的另一个用处是能够确保日志输出的时候是按照过滤器的说明限制的,也让过滤器也作为一项输出写到日志中。
具体的logcat详解,可以查看点击这里。
------头文件
#import <Foundation/Foundation.h>
#include <mach/mach_time.h>
@interface TimeStampHelper : NSObject
+ (NSTimeInterval)timestamp;
@end
----实现文件
#import "TimeStamp.h"
@implementation TimeStampHelper
+ (NSTimeInterval)timestamp
{
// get the timebase info -- different on phone and OSX
mach_timebase_info_data_t info;
mach_timebase_info(&info);
// get the time
uint64_t absTime = mach_absolute_time();
// apply the timebase info
absTime *= info.numer;
absTime /= info.denom;
// convert nanoseconds into seconds and return
return (NSTimeInterval) ((double) absTime / 1000000000.0);
}
@end