WEB开发网
开发学院手机开发Android 开发 Android 开发总结之获取来电号码 阅读

Android 开发总结之获取来电号码

 2010-02-22 16:21:00 来源:WEB开发网   
核心提示:case TelephonyManager.CALL_STATE_OFFHOOK:Log.d(TAG, "OFFHOOK");break;}}}public class CustomPhoneStateListener extends PhoneStateListener {private stat

case TelephonyManager.CALL_STATE_OFFHOOK:

Log.d(TAG, "OFFHOOK");

break;

}

}

}

public class CustomPhoneStateListener extends PhoneStateListener {

private static final String TAG = "CustomPhoneStateListener";

@Override

public void onCallStateChanged(int state, String incomingNumber){

Log.v(TAG, "WE ARE INSIDE!!!!!!!!!!!");

Log.v(TAG, incomingNumber);

switch(state){

case TelephonyManager.CALL_STATE_RINGING:

Log.d(TAG, "RINGING");

break;

case TelephonyManager.CALL_STATE_IDLE:

Log.d(TAG, "IDLE");

break;

case TelephonyManager.CALL_STATE_OFFHOOK:

Log.d(TAG, "OFFHOOK");

break;

}

}

}

Java代码

  1. <?xml version="1.0" encoding="utf-8"?> 
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
  3.    package="com.xjgz" 
  4.    android:versionCode="1" 
  5.    android:versionName="1.0"> 
  6.   <application android:icon="@drawable/icon" android:label="@string/app_name"> 
  7.     <receiver android:name=".CustomBroadcastReceiver" > 
  8.       <intent-filter> 
  9.         <action android:name="android.intent.action.PHONE_STATE" />   
  10.       </intent-filter> 
  11.     </receiver> 
  12.   </application> 
  13.  
  14.   <uses-permission android:name="android.permission.READ_PHONE_STATE" /> 
  15.   <uses-sdk android:minSdkVersion="7" /> 
  16.  
  17. </manifest> 

上一页  1 2 3 

Tags:Android 开发 总结

编辑录入:coldstar [复制链接] [打 印]
赞助商链接