Hello everyone, does anyone know where i can implement this code so that i can purchase a mobile module.
Code -->In WebPageActivity.java file, add:
1-
import android.webkit.ValueCallback;
2-Inside the function "publicclass WebPageActivity extends ActivityBase" Add:
private ValueCallback<Uri> mUploadMessage;
privatefinalstaticintFILECHOOSER_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;
}
}
2.1. Inside "publicvoid onCreate(Bundle savedInstanceState)", Add:
m_viewWeb = new WebView(this);
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
WebPageActivity.this.startActivityForResult(
Intent.createChooser(i, "File Chooser"),
FILECHOOSER_RESULTCODE);
}
// For Android 3.0+
public void openFileChooser(ValueCallback uploadMsg,String acceptType) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
WebPageActivity.this.startActivityForResult(
Intent.createChooser(i, "File Browser"),
FILECHOOSER_RESULTCODE);
}
// For Android 4.1
public void openFileChooser(ValueCallback<Uri> uploadMsg,String acceptType, String capture) {
mUploadMessage = uploadMsg;
Intent i = new Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
WebPageActivity.this.startActivityForResult(
Intent.createChooser(i, "File Chooser"),
WebPageActivity.FILECHOOSER_RESULTCODE);
}