How to download files from webview Android?

It may be depends on the android build version problem, the below code will work successfully on 2.3+ builds, check this out, ourBrow.setWebViewClient(new WebViewClient() { @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { Log.d(“WEB_VIEW_TEST”, “error code:” + errorCode + ” – ” + description); } @Override public boolean shouldOverrideUrlLoading(WebView view, String … Read more

Android download manager completed

A broadcast is sent by the DownloadManager whenever a download completes, so you need to register a broadcast receiver with the appropriate intent action( ACTION_DOWNLOAD_COMPLETE ) to catch this broadcast: To register receiver registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); and a BroadcastReciever handler BroadcastReceiver onComplete=new BroadcastReceiver() { public void onReceive(Context ctxt, Intent intent) { // your code } … Read more

How to download a file from a server and save it in specific folder in SD card in Android?

Your download URL is not a link to any file. It’s a directory. Make sure its a file and exists. Also check your logcat window for error logs. One more suggestion, its always better to do a printStackTrace() in catch blocks instead of Logs. Its gives a more detailed view of the error. Change this … Read more

Download Manger not working in Android Pie 9.0 NetworkSecurityConfig: No Network Security Config specified, using platform default

This worked for me After Xiaomi mi A2 received software update notification today. what worked for me Add android:networkSecurityConfig=”@xml/network_security_config” in application tag <application android:name=”.ApplicationClass” android:allowBackup=”true” android:hardwareAccelerated=”false” android:icon=”@mipmap/ic_launcher” android:label=”@string/app_name” android:largeHeap=”true” android:networkSecurityConfig=”@xml/network_security_config” android:supportsRtl=”true” android:theme=”@style/AppTheme”> where network_security_config.xml <?xml version=”1.0″ encoding=”utf-8″?> <network-security-config> <base-config cleartextTrafficPermitted=”true” /> </network-security-config> Create xml under res directory and then network_security_config.xml in xml folder like in … Read more

Intent Action for Download Completion not visible in AndroidManifest.xml

You can do like this. DownloadManager downloadManager; downloadManager = (DownloadManager)getSystemService(Context.DOWNLOAD_SERVICE); Uri uri = Uri.parse(“http://xxx.apk”); DownloadManager.Request request = new DownloadManager.Request(uri); // You can choose network type request.setAllowedNetworkTypes(DownloadManager.Request.NETWORK_WIFI); downloadManager.getRecommendedMaxBytesOverMobile(getApplicationContext()); final long flag = downloadManager.enqueue(request); IntentFilter filter = new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE ); BroadcastReceiver receiver = new BroadcastReceiver(){ @Override public void onReceive(Context context, Intent intent) { long anotherFlag = intent.getLongExtra(DownloadManager.EXTRA_DOWNLOAD_ID,-1); … Read more