2

我想在 VS2012 中使用 dot42 拒绝来电,这是我的代码示例

[Receiver(Enabled = true)]
     [IntentFilter(
        Actions = new[] { "android.intent.action.PHONE_STATE" }, 
        Categories = new[] { Intent.CATEGORY_DEFAULT }, 
        Priority=2147483647)
    ]

    public class callReceiver : broadcastReceiver
    {
公共覆盖无效 OnReceive(上下文上下文,意图意图)
    {
        字符串 MSG_TYPE = intent.GetAction();
        if (MSG_TYPE.Equals("android.intent.action.PHONE_STATE"))
        {
            字符串状态 = intent.GetStringExtra(TelephonyManager.EXTRA_STATE);
            if (state.Equals(TelephonyManager.EXTRA_STATE_RINGING))
            {
                中止广播();
            }
        }
     }

    }
----------   
     Add Permission
        "[assembly: usesPermission(Android.Manifest.Permission.READ_PHONE_STATE)]"
        "[assembly: usesPermission(Android.Manifest.Permission.MODIFY_PHONE_STATE)]"
        "[assembly: usesPermission(Android.Manifest.Permission.CALL_PHONE)]"

----------

代码不起作用。可以帮忙吗?

4

0 回答 0