[英]Jump to Dialer or any default Caller App when clicking on a Preference item
My question is pretty closed to reacting-to-a-click-on-a-preference我的问题非常接近于对点击偏好做出反应
I want to use Intent + android:action in my R.xml.preferences file instead of setting up OnClickListener on a certain preference item as below我想在我的 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>
While I always encounter the exception虽然我总是遇到异常
android.content.ActivityNotFoundException:
No Activity found to handle Intent { act=android.intent.action.DIAL dat=+1112223333}
Is this idea possible, or I have to use OnClickListener?这个想法可行吗,或者我必须使用 OnClickListener?
Phone apps support Uri
's in the form of tel:XXX
.电话应用程序以
tel:XXX
的形式支持Uri
。
Change your android:data
value to "tel:1112223333"
将您的
android:data
值更改为"tel:1112223333"
See: https://developer.android.com/reference/android/content/Intent#ACTION_DIAL请参阅: 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 .
else getData() 是要拨打的电话号码的URI 或 tel: 显式电话号码的 URI 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.