奇怪的ActivityNotFoundException

时间:2018-07-14 14:05:36

标签: android url android-activity hyperlink

最近我收到此错误:

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=    launchParam=MultiScreenLaunchParams { mDisplayId=0 mBaseDisplayId=0 mFlags=0 } }

为什么会这样?我做了所有类似YT教程中的操作。我的代码的目标是建立到另一个站点的链接。这是我的代码:

 adres2 =" https://www.facebook.com/  ";

     c2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(adres2));
                startActivity(intent);

            }
        });

2 个答案:

答案 0 :(得分:4)

  

为什么会这样?

您的Uri无效。替换:

adres2 =" https://www.facebook.com/  ";

具有:

adres2 ="https://www.facebook.com/";

答案 1 :(得分:0)

请更改代码并测试以下代码:

       llShare.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
             Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
// Add data to the intent, the receiving app will decide what to do with it.
                shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Welcome to Facebook!");
            shareIntent.putExtra(Intent.EXTRA_TEXT,"SOME DATA IN STRING FORM");

                startActivity(Intent.createChooser(shareIntent, "Share link!"));
            }
        });