0

In my web view, I have this code. When I'm clicking a link in my web view application stops nd shows try again to open app.

myWebView.setDownloadListener(new DownloadListener() {

    public void onDownloadStart(String url, String userAgent, String 
      contentDisposition, String mimetype, long contentLength) {

        DownloadManager.Request request = new 
            DownloadManager.Request(Uri.parse(url));

        CookieManager cookieManager = CookieManager.getInstance();
        String cookie = 
            cookieManager.getCookie("https://learntatatrusts.org/");
        request.addRequestHeader("Cookie", cookie);
        request.allowScanningByMediaScanner();
        Environment.getExternalStorageDirectory();
        getApplicationContext().getFilesDir().getPath(); 
        request.setNotificationVisibility(DownloadManager.Request.
            VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
        request.setDestinationInExternalPublicDir(Environment.
            DIRECTORY_DOWNLOADS, "download");
        DownloadManager dm = (DownloadManager) 
            getSystemService(DOWNLOAD_SERVICE);
        dm.enqueue(request);
    }
});
Pang
  • 9,564
  • 146
  • 81
  • 122
Nishanth Singh
  • 51
  • 1
  • 2
  • 7
  • can you post the error message? – Rob Sep 19 '17 at 11:23
  • app has stopped..!!! this wil showing after clicking a pdf link in webview – Nishanth Singh Sep 19 '17 at 11:29
  • I got that, but still you should get an error message on your Logcat. Look: https://www.youtube.com/watch?v=B1Mko9TD8DI – Rob Sep 19 '17 at 11:41
  • ANDROID_EMU_dma_v1 09-19 17:21:13.615 6023-6023/com.example.nisha.ttla E/chromium: [ERROR:interface_registry.cc(104)] Failed to locate a binder for interface: autofill::mojom::PasswordManagerDriver 09-19 17:21:24.702 6023-6023/com.example.nisha.ttla E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.nisha.ttla, PID: 6023 – Nishanth Singh Sep 19 '17 at 11:52
  • /storage/emulated/0/Download/download: Neither user 10083 nor current process has android.permission.WRITE_EXTERNAL_STORAGE. at android.os.Parcel.readException(Parcel.java:1684) at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:183) – Nishanth Singh Sep 19 '17 at 11:52
  • at android.content.ContentResolver.insert(ContentResolver.java:1276) at android.app.DownloadManager.enqueue(DownloadManager.java:1014) at com.example.nisha.ttla.MainActivity$1.onDownloadStart(MainActivity.java:58) – Nishanth Singh Sep 19 '17 at 11:53
  • (WebViewContentsClientAdapter.java:1051) at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:162) at android.os.Handler.dispatchMessage(Handler.java:102) – Nishanth Singh Sep 19 '17 at 11:54
  • at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6119) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit – Nishanth Singh Sep 19 '17 at 11:54
  • .java:886) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776) – Nishanth Singh Sep 19 '17 at 11:54
  • i'm glad that you found the error! did you know you can actually edit your question so you can add any missing info? next time it will be easier than posting on the comments below ;) – Rob Sep 19 '17 at 12:12
  • yes i wil do it next time..!! – Nishanth Singh Sep 19 '17 at 12:21

2 Answers2

1

I think you need to ask for permission at runtime as well, no only in Android Manifest file. You can check it out here:

https://developer.android.com/training/permissions/requesting.html#explain

And here:

How to check Grants Permissions at Run-Time?

Rob
  • 2,243
  • 4
  • 29
  • 40
0
Neither user 10083 nor current process has android.permission.WRITE_EXTERNAL_STORAGE

Have you tried to request the permission WRITE_EXTERNAL_STORAGE in your Manifest?

r-hold
  • 941
  • 8
  • 30