Can someone explain me how I would be able to imitate the default browser when trying to download .apk from the net?
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?
Thank you in advance!
But a wide variety of other Android applications also use it to display web content that isn't a part of the app. The WebView app is based on Chromium, the same open source project that powers the Google Chrome web browser, but it doesn't include all the features present in the full version of Chrome.
Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.
Android WebView is a system component for the Android operating system (OS) that allows Android apps to display content from the web directly inside an application.
Use an Intent
Intent intent = new Intent(Intent.ACTION_VIEW ,Uri.parse("http://dacp.jsharkey.org/TunesRemote-r2.apk"));
startActivity(intent);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With