Reputation: 113
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.
Upvotes: 3
Views: 846
Reputation: 718
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
Upvotes: 1