Go Back   Android Forums > Android Discussion > Android Applications
Android Applications All the information you could ever want about Android Applications. Learn about apps and get help with them... all here! New apps can be found and announced in the Applications Announcements forum linked below.

New Forums: Nexus Player | Nexus 9
test: Reply
 
LinkBack Thread Tools
Old October 1st, 2012, 12:38 PM   #1 (permalink)
New Member
Thread Author (OP)
 
Join Date: Oct 2012
Posts: 2
 
Device(s):
Carrier: Not Provided

Thanks: 0
Thanked 0 Times in 0 Posts
Angry File Upload Button does nto work in a Webview

I need to be able to open a file upload menu from AndroidAddMember.aspx page in a web view. I found this fix but I dont think im implementing it correctly.

m0s' programming adventure: File upload in through WebView on Android

The file upload button works fine in a browser on phone and pc but once in a web view the button does not work.
I embed the page with the button in my first case statement below.
Do i need to set the web view differently in that case statement to get the code above it to work? I wrapped the new code in these brackets //+++++++++++++++++++++

Any help would be great. Thanks
//+++++++++++ New Code to fix the button issue+++++++++++++++
WebView wv;
private ValueCallback<Uri> mUploadMessage;
private final static int FILECHOOSER_RESULTCODE=1;
@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;

}
}


public void onCreate1(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

wv = new WebView(this);
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/*");
MyGreatActivity.this.startActivityForResult(Intent .createChooser(i,"File Chooser"), FILECHOOSER_RESULTCODE);

}
});

setContentView(wv);
}

//++++++++++++++ End of new code to fix the button issue +++++++++++++++++++++
@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle item selection
switch (item.getItemId()) {
case R.id.register:
mWebView2 = (WebView) findViewById(R.id.webview);
mWebView2.getSettings().setJavaScriptEnabled(true) ;
mWebView2.loadUrl("http://www.Mysite.com/AndroidAddMember.aspx");
mWebView2.setWebViewClient(new HelloWebViewClient());
return true;
case R.id.ratewomen:
mWebView3 = (WebView) findViewById(R.id.webview);
mWebView3.getSettings().setJavaScriptEnabled(true) ;
mWebView3.loadUrl("http://mysite.com/gadgets.aspx");
mWebView3.setWebViewClient(new HelloWebViewClient());
return true;
case R.id.ratemen:
mWebView4 = (WebView) findViewById(R.id.webview);
mWebView4.getSettings().setJavaScriptEnabled(true) ;
mWebView4.loadUrl("http://mysite.com/gadgetsmall.aspx");
mWebView4.setWebViewClient(new HelloWebViewClient());
return true;
default:
return super.onOptionsItemSelected(item);
}
}

Advertisements
Foxcitiesjd is offline  
Reply With Quote
sponsored links
Reply
Tags
file-upload, fileupload, webview


Go Back   Android Forums > Android Discussion > Android Applications
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 05:21 AM.
Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.