学习Android闹钟源代码(一)-代码准备

由于自己的一个应用提醒是很重要的一部分,所以就得好好学习下Android自带的闹钟的实现了。

android自带应用在源代码目录的package/apps目录下。

闹钟应用的名字叫做DeskClock(说明:我下载的是android4.1的源代码)

(1)将DeskClock复制一份到工作目录中,

因为它本身不能直接导入到Eclipse中,我们可以到其它的android项目中,将.project和.classpath(这两个是隐藏文件)


项目文件复制一份到DeskClock中。并手动打开修改。

 或者。像下面这样:使用android update project 命令来

banxi1988@banxi:~ /android/tmp/DeskClock $ ls -a
.   AndroidManifest.xml  assets        .git                    NOTICE  src
..  Android.mk           CleanSpec.mk  MODULE_LICENSE_APACHE2  res     tests
banxi1988@banxi:~ /android/tmp/DeskClock $

  

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
banxi1988@banxi:~ /android/tmp/DeskClock $ android update project -p .  -s  -t 6
Updated and renamed default.properties to project.properties
Updated local .properties
No project name specified, using Activity name 'DeskClock' .
If you wish to change it, edit the first line of build.xml.
Added file . /build .xml
Added file . /proguard-project .txt
Updated and renamed default.properties to project.properties
Updated local .properties
No project name specified, using Activity name 'TestAddAlarm' .
If you wish to change it, edit the first line of build.xml.
Added file . /tests/build .xml
Added file . /tests/proguard-project .txt
banxi1988@banxi:~ /android/tmp/DeskClock $ ls -a
.                    assets        local .properties        project.properties
..                   build.xml     MODULE_LICENSE_APACHE2  res
AndroidManifest.xml  CleanSpec.mk  NOTICE                  src
Android.mk           .git          proguard-project.txt    tests
banxi1988@banxi:~ /android/tmp/DeskClock $

现在你发现了build.xml于是可以使用此文件在Eclipse中将项目导入了。android update project的具体使用参见其它文档。你懂的。

然后,我们就可以尝试编译运行DeskClock了。如果原来的虚拟机或者机子上已经有这个应用了,

那应该做出些修改。如更改包名等等。。


你可能感兴趣的:(学习Android闹钟源代码(一)-代码准备)