2
iam使用PhoneStateListener
我想監聽是否從Viper或Skype或任何類似的東西進行VoIP呼叫,iam實現監聽PhoneStateListener.LISTEN_DATA_ACTIVITY
,但它不工作寫。這裏是我的代碼如何爲VoIP撥打PhoneStateListener
public class VoIPDetectionActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
TelephonyManager obj = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
PhoneStateListener listener1 = new PhoneStateListener(){
@Override
public void onDataActivity (int direction){
String stateString = "N/A";
switch (direction) {
case TelephonyManager.DATA_ACTIVITY_NONE:
stateString = "Idle";
break;
case TelephonyManager.DATA_ACTIVITY_IN:
stateString = "Off Hook";
break;
case TelephonyManager.DATA_ACTIVITY_INOUT:
stateString = "Ringing";
break;
case TelephonyManager.DATA_ACTIVITY_OUT:
stateString = "Ringing";
break;
}
}
};
// Register the listener with the telephony manager
obj.listen(listener1, PhoneStateListener.LISTEN_DATA_ACTIVITY);
}
IAM歌廳TelephonyManager.DATA_ACTIVITY_NONE
但不是別人,任何人可以幫助我?在此先感謝