English 中文(简体)
当用户使用android:autoLink=“phone”点击文本框时,应用程序崩溃
原标题:Application crashes when user clicks on textbox with android:autoLink="phone"
  • 时间:2011-05-25 03:34:27
  •  标签:
  • android

所以,我有一个属性设置为突出显示手机的TextView。当我点击手机时,我会得到以下信息:

ERROR/AndroidRuntime(4853): FATAL EXCEPTION: main
        android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity  context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
        at android.app.ContextImpl.startActivity(ContextImpl.java:624)
        at android.content.ContextWrapper.startActivity(ContextWrapper.java:258)
        at android.text.style.URLSpan.onClick(URLSpan.java:62)
        at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:216)
        at android.widget.TextView.onTouchEvent(TextView.java:6863)
        at android.view.View.dispatchTouchEvent(View.java:3885)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
        at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
        at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
        at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
        at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
        at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:130)
        at android.app.ActivityThread.main(ActivityThread.java:3683)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)

我认为这可能与我的Activity实现BaseActivity(抽象类)这一事实有关。但是我该如何解决这个问题呢?其他一切似乎都很好。

最佳回答

链接可能会有所帮助。这基本上是在暗示您正试图使用非当前活动中的上下文来启动活动。(要么是这样,要么您不在活动中…)

问题回答

我想你想点击那个号码打个电话,对吧?

然后为了这个目的,你可以把它作为:

String uri = "tel:" + phoneNo.trim() ;    //phoneNo is String variable which contains your no
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse(uri));
startActivity(intent);




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签