2012-06-05 47 views
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但不是別人,任何人可以幫助我?在此先感謝

回答

1

這可能無法正常工作的一些原因。大多數情況下,VoIP會通過wifi發送,PhoneStateListener.LISTEN_DATA_ACTIVITY僅適用於手機。另外,我不確定Vi蛇,但Skype使用它自己的VoIP協議,在混合中引發另一個扳手。

一個可能的解決方案是輪詢AudioManager的通信模式。

下面是顯示某人設置的鏈接。

How implement the VOIP application using android.net.rtp package