I'm looking to make a customized phone log and was wondering if there 开发者_开发问答was some kind of built-in Android library that lets your app receive phone calls and then get the phone number or data from the phone call. That way I can store it in my customized phone log.
You should use Android's Telephony Manager for this:
http://developer.android.com/reference/android/telephony/TelephonyManager.html
You need to hook your application up to the ACTION_PHONE_STATE_CHANGED intent. The intent comes with a few extras, and one of them is EXTRA_INCOMING_NUMBER -- which contains the phone # as a string.
This site has a pretty good example:
http://www.tutorialforandroid.com/2009/01/get-phone-state-when-someone-is-calling_22.html
精彩评论