0

是否可以使用使用模式的链接进行呼叫?我想在文本视图中显示文本“呼叫存储”。当我单击该文本视图时需要拨打给定号码。为此,我尝试了下面的代码。

Linkify.addLinks(callStoreTxt ,pattern,"9465789002" );

这里 callStoretxt 是我的文本视图的名称。但它崩溃了。有什么办法吗?编辑:我的崩溃日志

 07-11 15:11:02.361: E/AndroidRuntime(31906): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=seethalakshmi.may2009@gmail.comS (has extras) }
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1512)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.app.Instrumentation.execStartActivity(Instrumentation.java:1384)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.app.Activity.startActivityForResult(Activity.java:3190)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.support.v4.app.FragmentActivity.startActivityForResult(Unknown Source)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.app.Activity.startActivity(Activity.java:3297)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.text.style.URLSpan.onClick(URLSpan.java:62)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:212)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.widget.TextView.onTouchEvent(TextView.java:8344)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.View.dispatchTouchEvent(View.java:5541)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent (ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at   android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:1957)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1726)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1912)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at  com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1371)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.app.Activity.dispatchTouchEvent(Activity.java:2364)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1860)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.View.dispatchPointerEvent(View.java:5721)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at  android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:2890)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewRootImpl.handleMessage   (ViewRootImpl.java:2466)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewRootImpl.processInputEvents(ViewRootImpl.java:845)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2475)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.os.Handler.dispatchMessage(Handler.java:99)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.os.Looper.loop(Looper.java:137)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at android.app.ActivityThread.main(ActivityThread.java:4424)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at java.lang.reflect.Method.invokeNative(Native Method)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at java.lang.reflect.Method.invoke(Method.java:511)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
 07-11 15:11:02.361: E/AndroidRuntime(31906):   at dalvik.system.NativeStart.main(Native Method)
4

1 回答 1

0

您可以使用 HTML(使用 'tel' 协议)来做到这一点:

TextView textView = new TextView(this);
textView.setText(Html.fromHtml("<a href='tel:9465789002'>Call store</a>"));
textView.setMovementMethod(LinkMovementMethod.getInstance());

setMovementMethod()TextView 中启用链接。

于 2012-07-11T11:55:45.757 回答