strange ActivityNotFoundException



最近我收到了这个错误:

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);
}
});

为什么会发生这种情况?

您的Uri无效。替换:

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

带有:

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

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

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!"));
}
});

最新更新