In my app, i am loading "http" url in the webview. This url is loaded correctly, but there are some internal url's loaded with the protocol "sheet://". While loading this url i get an error "protocol isn't supported". Can anyone please help how to fix this? How to load the url's with the protocol "sheet://" ?
PS: I am using shouldOverrideUrlLoading method to load the url.
This is the code I am using
public boolean shouldOverrideUrlLoading(WebView view, String url) {
if(url.contains("sheet://")){
Intent url_intent = new Intent ( Intent.ACTION_VIEW,Uri.parse(url));
url_intent.addCategory(Intent.CATEGORY_BROWSABLE);
startActivity(url_intent);
return false;
}else{
view.loadUrl(url);
return true;
}
}
Thanks & Regards,
Perhaps host an PHP file, with an header?
<?php
header("Location: sheet://link_to_your_file.extention");
?>
Do you see the call to shouldOverrideUrlLoading
come in for your sheet:// URL? That part of the code looks correct (assuming there is an app installed on your device that can handle sheet:// BROWSABLE intents). Or do you mean that the app launched from your app cannot load the sheet:// URL? What app is being launched to respond to the Intent?
One mistake you have is the call to loadUrl
when sheet:// is not in the URL. In this case, please just return true
. The URL load is already in progress, there is no need to start it again. Doing so infact creates a loop.
您必须在AndroidManifest.xml中使用与该协议匹配的意图过滤器注册活动
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.