簡體   English   中英

如何獲得參考號BroadcastReceiver獨角獸?

[英]How to get a reference number BroadcastReceiver monodroid?

如何獲得參考號? 以下代碼返回null:

[BroadcastReceiver]

[IntentFilter(new[] { "android.intent.action.PHONE_STATE" }, Priority = (int)IntentFilterPriority.HighPriority)]
public class Telefon : BroadcastReceiver
{
    public override void OnReceive(Context context, Intent intent)
    {
        if (intent.GetStringExtra(TelephonyManager.ExtraState).Equals(TelephonyManager.ExtraStateOffhook))
        {
            string telephone = intent.GetStringExtra(Intent.ExtraPhoneNumber);

            Bundle bundle = intent.Extras;
            string telephone_2 = bundle.GetString("outgoing_number");

            Toast toast = Toast.MakeText(context, telephone + "\n" + telephone_2, ToastLength.Long); //return null;
            toast.Show();
        }
}

您是否配置了正確的權限?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM