Cordova inappbrowser 不播放媒体或下载 .ics 日历文件
Cordova inappbrowser does not play media or download .ics calendar file
我正在加载我无法控制的外部 website
、下载 buttons
或旨在在其他地方打开的链接,例如 .ics or.pdf 文件没有任何效果或操作,例如使用默认 application
在 app
本身上打开它。
这是代码
onDeviceReady: function() {
var openWindow = function() {
var ref = cordova.InAppBrowser.open('https://www.example.com', '_blank', 'location=yes,zoom=no,toolbar=no,enableViewportScale=yes');
ref.addEventListener('exit', function(event) { navigator.app.exitApp()
navigator.notification.activityStart("", "loading");
});
var loadStop = function(event) {
navigator.notification.activityStop();
ref.removeEventListener('loadstop', loadStop);
};
ref.addEventListener('loadstop', loadStop);
};
我以某种方式找到了一种在 android 上解决问题的方法,在插件 inappbrowser.java 中,在这条路径上:\platforms\android\app\src\main\java\org\apache\cordova\inappbrowser
在此方法中,我添加了更多参数以获取 .pdf 和 .ics 文件
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
if (url.endsWith(".pdf")){
try{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
intent.setPackage("com.android.chrome");
cordova.getActivity().startActivity(intent);
return true;
}catch(android.content.ActivityNotFoundException e){
LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
}
} else if (url.contains("/icsdownload/")){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
}
}
我还指定了打开哪个特定包。
我可以邀请 ios 部分的帮助
我正在加载我无法控制的外部 website
、下载 buttons
或旨在在其他地方打开的链接,例如 .ics or.pdf 文件没有任何效果或操作,例如使用默认 application
在 app
本身上打开它。
这是代码
onDeviceReady: function() {
var openWindow = function() {
var ref = cordova.InAppBrowser.open('https://www.example.com', '_blank', 'location=yes,zoom=no,toolbar=no,enableViewportScale=yes');
ref.addEventListener('exit', function(event) { navigator.app.exitApp()
navigator.notification.activityStart("", "loading");
});
var loadStop = function(event) {
navigator.notification.activityStop();
ref.removeEventListener('loadstop', loadStop);
};
ref.addEventListener('loadstop', loadStop);
};
我以某种方式找到了一种在 android 上解决问题的方法,在插件 inappbrowser.java 中,在这条路径上:\platforms\android\app\src\main\java\org\apache\cordova\inappbrowser
在此方法中,我添加了更多参数以获取 .pdf 和 .ics 文件
public boolean shouldOverrideUrlLoading(WebView webView, String url) {
if (url.endsWith(".pdf")){
try{
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
intent.setPackage("com.android.chrome");
cordova.getActivity().startActivity(intent);
return true;
}catch(android.content.ActivityNotFoundException e){
LOG.e(LOG_TAG, "Error with " + url + ": " + e.toString());
}
} else if (url.contains("/icsdownload/")){
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(url));
cordova.getActivity().startActivity(intent);
}
}
我还指定了打开哪个特定包。 我可以邀请 ios 部分的帮助