单击首选项项时跳转到拨号程序或任何默认的呼叫者应用程序

Jump to Dialer or any default Caller App when clicking on a Preference item

我的问题很接近 reacting-to-a-click-on-a-preference

我想在我的 R.xml.preferences 文件中使用 Intent + android:action 而不是如下所示在某个首选项上设置 OnClickListener

    <Preference android:title="@string/pref_cat3_call_center">
        <intent
            android:action="android.intent.action.DIAL"
            android:data="1112223333" />
    </Preference>

虽然我总是遇到异常

android.content.ActivityNotFoundException: 
No Activity found to handle Intent { act=android.intent.action.DIAL dat=+1112223333}

这个想法可行吗,还是我必须使用OnClickListener?

Phone 应用程序支持 Uri 的格式为 tel:XXX

将您的 android:data 值更改为 "tel:1112223333"

参见:https://developer.android.com/reference/android/content/Intent#ACTION_DIAL

Input: If nothing, an empty dialer is started; else getData() is URI of a phone number to be dialed or a tel: URI of an explicit phone number.