自由行, 游览 Android 的官方源码
初学者或许会问到 :
"编写软件,需要了解 android 源码吗 ? 我需要了解 android 内部的运作吗 ?"
其实一般的 app,只需要使用普通 java 便可以编写完成
可是你会渐渐发现,别人的 app,总是做到了某些特别的功能,那些优秀的功能,都不是使用一般方法便可以做到的
因为android 软件使用 java 平台的关系,我们可以使用 java 的 reflection 来进行 java 对象的深入操作,使用官方 SDK 没有公开的功能,做到更多效果
经过 google 查了一下,你便会发现,了解 android 源码设计,会使你了解 android 更多
这个帖是集中讨论阅读源码,这里使用网上 git 来提供参考 (当然鼓励大家用 git 把整份源码下载到 pc 上)
如果大家有甚么问题或发现,欢迎讨论
网上git 查看 android 源码的方法 :
http://android.git.kernel.org/
这里是 android project 的源码,假如你想查看某一个目录,只需要在那一行,按 tree,便会打开
eg:
系统架构 :
platform/frameworks/base.git
按 tree 打开
drwxr-xr-x - api tree | history
drwxr-xr-x - build tree | history
drwxr-xr-x - cmds tree | history
drwxr-xr-x - core tree | history
drwxr-xr-x - data tree | history
drwxr-xr-x - docs tree | history
drwxr-xr-x - drm tree | history
drwxr-xr-x - graphics tree | history
drwxr-xr-x - include tree | history
drwxr-xr-x - keystore tree | history
drwxr-xr-x - libs tree | history
drwxr-xr-x - location tree | history
drwxr-xr-x - media tree | history
我们假如对 android 的 "Bitmap" 这个class 有兴趣,便前往
graphics (按 tree)
drwxr-xr-x ..
drwxr-xr-x - java tree | history
drwxr-xr-x - jni tree | history
drwxr-xr-x - tests tree | history
然后,继续进入 -> java -> android -> graphics
(完整位置 : [platform/frameworks/base.git] / graphics / java / android / graphics / )
便会看见
-rw-r--r-- 2388 AvoidXfermode.java blob | history | raw
-rwxr-xr-x 676 Bitmap.aidl blob | history | raw
-rw-r--r-- 42136 Bitmap.java blob | history | raw
-rw-r--r-- 25562 BitmapFactory.java blob | history | raw
-rw-r--r-- 11435 BitmapRegionDecoder.java blob | history | raw
-rw-r--r-- 1542 BitmapShader.java blob | history | raw
-rw-r--r-- 1783 BlurMaskFilter.java blob | history | raw
-rw-r--r-- 1594 Camera.java blob | history | raw
打开 Bitmap.java ,便可以看到 Bitmap 的设计了
[CTF入门培训]顶尖高校博士及硕士团队亲授《30小时教你玩转CTF》,视频+靶场+题目!助力进入CTF世界