Commit c0c3fdee authored by crazecoder's avatar crazecoder

fix crash

parent b800d0f6
package com.pichillilorenzo.flutter_inappbrowser.InAppWebView; package com.pichillilorenzo.flutter_inappbrowser.InAppWebView;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
...@@ -521,18 +522,23 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis ...@@ -521,18 +522,23 @@ public class InAppWebChromeClient extends WebChromeClient implements PluginRegis
FileChooserParams fileChooserParams) { FileChooserParams fileChooserParams) {
mUploadMessageArray = filePathCallback; mUploadMessageArray = filePathCallback;
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT); try {
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.setType("*/*"); contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
Intent[] intentArray; contentSelectionIntent.setType("*/*");
intentArray = new Intent[0]; Intent[] intentArray;
intentArray = new Intent[0];
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent); Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser"); chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray); chooserIntent.putExtra(Intent.EXTRA_TITLE, "Image Chooser");
((inAppBrowserActivity != null) ? inAppBrowserActivity : flutterWebView.activity).startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
return super.onShowFileChooser(webView, filePathCallback, fileChooserParams); ((inAppBrowserActivity != null) ? inAppBrowserActivity : flutterWebView.activity).startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE);
} catch (ActivityNotFoundException e) {
e.printStackTrace();
return false;
}
return true;
} }
private MethodChannel getChannel() { private MethodChannel getChannel() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment