[英]How to imitate default browser to download .apk files from webview?
Can someone explain me how I would be able to imitate the default browser when trying to download .apk from the net? 有人可以解释我在尝试从网上下载.apk时如何模仿默认浏览器吗?
So far I have this: 到目前为止我有这个:
WebView webview;
@Override
public void onCreate(Bundle icicle)
{
super.onCreate(icicle);
setContentView(R.layout.main);
webview = (WebView) findViewById(R.id.webview);
webview.setWebViewClient(new HelloWebViewClient());
WebSettings webSettings = webview.getSettings();
webSettings.setSavePassword(false);
webSettings.setSaveFormData(false);
webSettings.setJavaScriptEnabled(true);
webSettings.setSupportZoom(false);
webview.setDownloadListener(new DownloadListener() {
public void onDownloadStart(final String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Toast.makeText(testapp.this, url, Toast.LENGTH_LONG);
}
});
webview.loadUrl("http://dacp.jsharkey.org/TunesRemote-r2.apk");
}
I've already added the permission to use the internet. 我已经添加了使用互联网的许可。 Are there any other permissions that I need to add? 我还需要添加其他权限吗? Am I doing the DownloadListener incorrectly? 我不正确地做了DownloadListener吗?
Thank you in advance! 先感谢您!
Use an Intent 使用意图
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("http://dacp.jsharkey.org/TunesRemote-r2.apk"));
startActivity(intent);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.