Android-在外部浏览器中打开url会导致无限循环
默认情况下,我的应用程序可以使用以下方法打开链接:Android-在外部浏览器中打开url会导致无限循环,android,android-intent,Android,Android Intent,默认情况下,我的应用程序可以使用以下方法打开链接: <category android:name="android.intent.category.BROWSABLE" /> <data android:host="example.com" android:scheme="http" /> <data android:host="www.example.com" android:
<category android:name="android.intent.category.BROWSABLE" />
<data
android:host="example.com"
android:scheme="http" />
<data
android:host="www.example.com"
android:scheme="http" />
....
我所期望的是,它将在浏览器上打开,但如果用户选择默认情况下应用程序将打开所有链接(“始终打开”而不是“仅打开一次”),应用程序将再次调用并再次将链接发送到浏览器-这会导致无限循环。
如何避免这种情况?
你试过使用像google.com之类的有效网站吗?是的。我用正确的URL尝试了它,你直接把它放在我的应用程序中,例如我不在mi XML
startActivity中创建“数据”(new Intent(Intent.ACTION\u VIEW,Uri.parse(“www.google.es”))代码>
String requestURL = "www.example.com/unsupportedlink";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(requestURL));
mActivity.startActivity(i);
Uri uri = Uri.parse(requestURL);
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setDataAndType(uri, "text/html");
browserIntent.addCategory(Intent.CATEGORY_BROWSABLE);
context.startActivity(browserIntent);