android - 找不到处理意图action.VIEW的Activity

时间:2015-06-18 18:40:40

标签: android exception android-intent android-fragments textview

我的Android应用程序出现异常:

06-18 17:57:39.816    6333-6333/com.appsrox.instachat E/InputEventReceiver﹕ Exception dispatching input event.
06-18 17:57:39.816    6333-6333/com.appsrox.instachat E/MessageQueue-JNI﹕ Exception in MessageQueue callback: handleReceiveCallback
06-18 17:57:39.816    6333-6333/com.appsrox.instachat E/MessageQueue-JNI﹕ android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) }
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
            at android.app.Activity.startActivityForResult(Activity.java:3745)
            at android.app.Activity.startActivityForResult(Activity.java:3706)
            at android.app.Activity.startActivity(Activity.java:4016)
            at android.app.Activity.startActivity(Activity.java:3984)
            at android.text.style.URLSpan.onClick(URLSpan.java:62)
            at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:217)
            at android.widget.TextView.onTouchEvent(TextView.java:7985)
            at android.view.View.dispatchTouchEvent(View.java:8471)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
            at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
            at android.view.View.dispatchPointerEvent(View.java:8666)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807)
            at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781)
            at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5752)
            at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:5897)
            at android.view.InputEventReceiver.dispatchInputEvent(I
06-18 17:57:39.816    6333-6333/com.appsrox.instachat D/AndroidRuntime﹕ Shutting down VM
06-18 17:57:39.817    6333-6333/com.appsrox.instachat E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.appsrox.instachat, PID: 6333
    android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) }
            at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1781)
            at android.app.Instrumentation.execStartActivity(Instrumentation.java:1501)
            at android.app.Activity.startActivityForResult(Activity.java:3745)
            at android.app.Activity.startActivityForResult(Activity.java:3706)
            at android.app.Activity.startActivity(Activity.java:4016)
            at android.app.Activity.startActivity(Activity.java:3984)
            at android.text.style.URLSpan.onClick(URLSpan.java:62)
            at android.text.method.LinkMovementMethod.onTouchEvent(LinkMovementMethod.java:217)
            at android.widget.TextView.onTouchEvent(TextView.java:7985)
            at android.view.View.dispatchTouchEvent(View.java:8471)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2405)
            at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:2106)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2369)
            at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1719)
            at android.app.Activity.dispatchTouchEvent(Activity.java:2742)
            at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2330)
            at android.view.View.dispatchPointerEvent(View.java:8666)
            at android.view.ViewRootImpl$ViewPostImeInputStage.processPointerEvent(ViewRootImpl.java:4123)
            at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:3989)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:3680)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:3737)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:3597)
            at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:3563)
            at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:3571)
            at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:3544)
            at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:5807)
            at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:5781)
            at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:5752)
            at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:
06-18 17:57:39.818    1228-1596/system_process W/ActivityManager﹕ Force finishing activity 1 com.appsrox.instachat/.ChatActivity

当用户在文本中单击URL时会发生这种情况。我有一个包含TextView的布局的listfragment。我正在使用Android Studio中的Android设备模拟器进行测试。

当用户点击带有网址的文字中的网址时会发生这种情况。 它的意思是什么? 如果我需要在文本中点击Urls,我该如何修复此错误?

我的Android设备有浏览器。 这是我做 TextView html设置的部分:

TextView tvhtml = (TextView) view;
final String html="<a href="http://www.google.com">Go to Google</a>";
tvhtml.setLinksClickable(true);
tvhtml.setMovementMethod (LinkMovementMethod.getInstance());
tvhtml.setText(Html.fromHtml(html));

以下是我的应用中的一些代码段:

    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
            super.onActivityCreated(savedInstanceState);
            getListView().setDivider(null);
            getListView().setSelector(R.drawable.selector_items);
            Bundle args = new Bundle();
            args.putString(DataProvider.COL_EMAIL, mListener.getProfileEmail());
            getLoaderManager().initLoader(0, args, this);
            this.postMesagesCAB();
    }
    .....

    ....

    adapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
            @Override
            public boolean setViewValue(View view, Cursor cursor, int columnIndex) {
                switch (view.getId()) {
                    case R.id.text1:
                     TextView tvhtml = (TextView) view;
                     final String html="<a href="http://www.google.com">Go to Google</a>";
                     tvhtml.setLinksClickable(true);
                     tvhtml.setMovementMethod ( LinkMovementMethod.getInstance());
                     tvhtml.setText(Html.fromHtml(html));

    ...}

    private void postMesagesCAB() {
            final ListView listView = getListView();
            listView.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE_MODAL);

            listView.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {

            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                    ((ListView) parent).setItemChecked(position,
                            ((ListView) parent).isItemChecked(position));
                    //view.setBackgroundColor(Color.CYAN);
                return false;
                }
            });
            listView.setMultiChoiceModeListener(new AbsListView.MultiChoiceModeListener() {
                //private int nr = 0;

                @Override
                public void onItemCheckedStateChanged(ActionMode mode, int position,
                                                      long id, boolean checked) {
                    // Here you can do something when items are selected/de-selected,
                    // such as update the title in the CAB
                    Cursor c = ((SimpleCursorAdapter)listView.getAdapter()).getCursor();
                    c.moveToPosition(position);
                    String item = c.getString(0);

                    if (checked) {
                        nr++;
                    } else {
                        nr--;
                    }
                    int fsize=checkedItemPositions.size();
                    mode.setTitle(String.format("%d ite%s selecionado%s", fsize, fsize==1 ? "m" : "ns", fsize==1 ? "" : "s"));
                    mode.invalidate();
                }

...

1 个答案:

答案 0 :(得分:7)

  

当用户点击文字中的网址

时会发生这种情况

在这种情况下,网址格式错误:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=href (has extras) }

网址为href。这不是有效的网址。

  

以下是我进行TextView html设置的部分:

这不会编译,因为它不是有效的Java。您不能使用包含引号的带引号的字符串。你需要逃避内部引号:

final String html="<a href=\"http://www.google.com\">Go to Google</a>";
  

如果我需要在文本中点击网址,我该如何解决此错误?

如果您是提供HTML的人,请确保它是有效的。