You can get the source code for the system apps (for example, the Dialer app is at https://android.googlesource.com/platform/packages/apps/Dialer/) and then modify it or use it as an example.
http://source.android.com/source/building.html might be useful to set up your dev environment to get the code.