2016-04-21 64 views
1

我想挂断从android的传出电话,但我无法检测到CALL_STATE_RINGINGXamarin android挂断了传出的呼叫?

这里我的代码示例:

[BroadcastReceiver()]  
[IntentFilter(new[] { "android.intent.action.NEW_OUTGOING_CALL", "android.intent.action.PHONE_STATE", "android.intent.action.PHONE_STATE_CHANGED" })] 
     class CallListener : BroadcastReceiver 
     {   
      public CallListener() 
      { 

      } 

      public override void OnReceive(Context context, Intent intent) 
      { 
       if (state == TelephonyManager.ExtraStateRinging) 
       { 
         //some code here 
       } 
      } 
     } 
+0

你不错过'[BroadcastReceiver]'属性吗? – Cheesebaron

+0

@Cheesebaron不,我不会在项目中忽略该属性。 – Atlantis

+0

所以你打OnReceive,但你不确定如何获得当前状态,或者是什么问题? – Cheesebaron

回答

0

重新检查你的意图过滤器,它必须是不正确的。用工作的android java samples/android doc来验证它。

此外,yhou不应该使用字符串,Xamarin将所有这些字符串转换为常量。困难的是找到它们。在TelephonyManager类上检查它们。