Android源码编译可执行文件 | 运行 | C层检测系统API版本号

来源:互联网 发布:java中string.split 编辑:程序博客网 时间:2024/06/06 21:42

readSdkLevel.cpp

view plain
  1. #include <cutils/properties.h>     
  2. #include <stdio.h>    
  3. #include <cstring>   
  4. void  print_prop( const   char * key, const   char * value, void * cookie)    
  5. {    
  6.     if(!strcmp(key, "ro.build.version.sdk"))  
  7.         printf("--key=%s,value=%s/n" ,key,value);    
  8. }    
  9.   
  10. int  main()    
  11. {    
  12.     property_list(print_prop,NULL);    
  13. }    

Android.mk

view plain
  1. LOCAL_PATH:= $(call my-dir)  
  2.   
  3. include $(CLEAR_VARS)  
  4.   
  5. LOCAL_SRC_FILES:= \  
  6. readSdkLevel.cpp \  
  7.   
  8. LOCAL_SHARED_LIBRARIES := \  
  9. libcutils \  
  10. libutils \  
  11.   
  12. LOCAL_MODULE:= list_prop  
  13.   
  14. include $(BUILD_EXECUTABLE)  
  15.   
  16. include $(call all-makefiles-under,$(LOCAL_PATH))  

运行

用adb push将二进制文件拷贝到系统的某个目录,然后运行。

./adb push list_prop /data/list_prop
# chmod 777 list_prop
# ./list_prop


转自 http://blog.csdn.net/stefzeus/article/details/6674998

原创粉丝点击