I need to open the menu for downloading files from the AndroidAddMember.aspx website in a web view. I found this fix, but I donβt think it is right for them to implement it. Fix
The file download button works fine in the browser on the phone and PC, but once in web mode the button does not work.
I insert a page with a button into my first case statement below.
Any help would be great. Thanks
@Override protected void onActivityResult(int requestCode, int resultCode, Intent intent) { if(requestCode==FILECHOOSER_RESULTCODE) { if (null == mUploadMessage) return; Uri result = intent == null || resultCode != RESULT_OK ? null : intent.getData(); mUploadMessage.onReceiveValue(result); mUploadMessage = null; } } @Override public boolean onOptionsItemSelected(MenuItem item) { // Handle item selection switch (item.getItemId()) { case R.id.register: wv = new WebView(this); wv.setWebViewClient(new WebViewClient()); wv.getSettings().setJavaScriptEnabled(true); wv.loadUrl("http://www.mysite.com/AndroidAddMember.aspx"); wv.setWebViewClient(new WebViewClient()); wv.setWebChromeClient(new WebChromeClient() { //The undocumented magic method override //Eclipse will swear at you if you try to put @Override here public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); Myactivity.this.startActivityForResult(Intent.createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE); } }); setContentView(wv); return true; default: return super.onOptionsItemSelected(item); } }
source share