Open the file download menu in a web view that does not work

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); } } 
+4
source share
1 answer

In fact, web browsing does not allow you to download a file in this way. Or you should create a download button in the menu of your application. And grab the file and then upload it to your website via http.

Or it is better to use a handset to make this possible. In the gap of the phone you can easily upload and download files.

http://docs.phonegap.com/en/2.1.0/cordova_file_file.md.html#File

Only in this way can you upload the file to your server or in any way. Webview provides only basic features.

you better use this method.

+3
source

Source: https://habr.com/ru/post/1437198/


All Articles