如果从 Viper 或 Skype 或任何类似的东西发出 VoIP 呼叫,我正在使用PhoneStateListener
我想收听,我正在实现侦听器,PhoneStateListener.LISTEN_DATA_ACTIVITY
但它无法正常工作。这是我的代码
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);
}
我得到了TelephonyManager.DATA_ACTIVITY_NONE
但没有其他人,有人可以帮我吗?提前致谢