I have a register page that has a file upload button on it. This is a aspx page in C#.
When i run it in a browser it works fine.
When i run it in a web view in an android app it does not launch the file menu in you android phone.
When i run the page in a browser on my android phone it lanuches the file menu on my phone just fine.
How do i get it to work in a web view.
My asp tag.
<asp:FileUpload ID="FileUpload1" runat="server" Height="30px" Width="217px" />
my android web view
case R.id.register:
mWebView2 = (WebView) findViewById(R.id.webview);
mWebView2.getSettings().setJavaScriptEnabled(true);
mWebView2.loadUrl("www.mysite.com/AndroidAddMember.aspx");
mWebView2.setWebViewClient(new HelloWebViewClient());
return true;
I tried to implement your code that you suplied. Im getting an error on FILECHOOSER_RESULTCODE now.
The error is FILECHOOSER_RESULTCODE cannot be resolved to a variable.
case R.id.register:
//mWebView2 = (WebView) findViewById(R.id.webview);
//mWebView2.getSettings().setJavaScriptEnabled(true);
//mWebView2.loadUrl("http://www.bangmeornot.com/AndroidAddMember.aspx");
//mWebView2.setWebViewClient(new HelloWebViewClient());
mWebView2.setWebChromeClient(new WebChromeClient()
{
//The undocumented magic method override
//Eclipse will swear at you if you try to put @Override here
public void openFileChooser(ValueCallback<URL> uploadMsg) {
ValueCallback<URL> mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
BangMeorNot.this.startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE);
}
});
return true;
Apparently the stock browser uses an undocumented method to accomplish file uploads. Here’s what you have to do to enable this functionality in your app:
Note: The exact parameters for this function have changed throughout the various versions of Android. For a solution which works across all Android versions, check out this question, or try using the parameters listed in this answer.