0

HI I have a website in Asp.net where I am using Data Tables with Export Buttons like CSV Excel Pdf

I have created a WebView android app for the site. But when I am clicking on any export button, the app crashes.

Here is my download code

 myWebview.setDownloadListener(new DownloadListener() {
                @Override
                public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) {
                    Intent i=new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(url));
                    startActivity(i);
                }
            });

and here is the the app crash Report

android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=blob:http://192.168.43.1/bb78f8da-62b4-4d4e-83a6-683f3a167f25 }
    at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1816)
    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1525)
    at android.app.Activity.startActivityForResult(Activity.java:4396)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
    at android.app.Activity.startActivityForResult(Activity.java:4355)
    at android.support.v4.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
    at android.app.Activity.startActivity(Activity.java:4679)
    at android.app.Activity.startActivity(Activity.java:4647)
    at in.gov.Example.MainActivity$1.onDownloadStart(MainActivity.java:78)
    at com.android.webview.chromium.Ap.onDownloadStart(WebViewContentsClientAdapter.java:485)
    at org.chromium.android_webview.AwContentsClientCallbackHelper$MyHandler.handleMessage(AwContentsClientCallbackHelper.java:25)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:165)
    at android.app.ActivityThread.main(ActivityThread.java:6375)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:883)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:773)

Please help me to fix this issue. I will be most thankful.

DEEP SECRETS
  • 83
  • 2
  • 8

1 Answers1

0

You don't have any app that has declared the intent filter of the type of data you want to view. You need to handle with try catch the exception while calling start activity for that intent if any activity is not found and you can search on playstore for the app which can di that work for you. Moreover the url u are calling does not define whether its html, pdf or csv Use: Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://site")); startActivity(browserIntent);

inside try catch block

  • Check **dat=blob:http://192.168.43.1/bb78f8da-62b4-4d4e-83a6-683f3a167f25.** I am getting this error because of **blob** URL. When click on any datatable export button like pdf or excel it generates blob URL. And I am not able to handle that. – DEEP SECRETS Mar 10 '19 at 07:44
  • I am already using try catch but I am not able to download from **DATATABLES** export buttons like csv pdf excel – DEEP SECRETS Mar 10 '19 at 08:45