La vista web de desarrollo de Android no funciona
El proyecto Os-FileUp en Github proporciona algunos métodos. webView.setWebChromeClient(new?WebChromeClient(){/For?Android?.
public?void?openFileChooser(ValueCallbackmUM?=? uploadMsg;
Intent?i?=?new?Intent(Intent.ACTION_GET_CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType ("imagen/*");
MainActivity.this.startActivityForResult(Intent.createChooser(i, "File?Chooser"),?FCR) ;
}//?For El método anterior no es compatible con la versión ?Android?..
+El método anterior no es compatible con la versión, en este caso usamos el siguiente método
public?void?openFileChooser(ValueCallback?uploadMsg,?String?acceptType){
mUM? =?uploadMsg;
Intent?i?=?new?Intent(Intent.ACTION_GET_ CONTENT);
i.addCategory(Intent.CATEGORY_OPENABLE);
i.setType("*/*");
MainActivity.this.startActivityForResult(
MainActivity.this.p>
Intent.createChooser(i, ?" ¿Archivo? Navegador"),
FCR);
}/For?.1+
public?void?openFileChooser(ValueCallback? uploadMsg,?String?acceptType,?String?capture){
mUM?=?uploadMsg;
Intent?i?=?new?Intent(Intent.ACTION_GET_CONTENT); p> p>
i.Add categoría(Intent.CATEGORY_OPENABLE);
i.setType("image/*");
MainActivity.this.startActivityForResult(Intent. createChooser( i,? "Selector de archivos"),?MainActivity.FCR);
}/Aplicable a Android?.
public?boolean?onShowFileChooser(
WebView?webView,?ValueCallback?filePathCallback,
WebChromeClient.FileChooserParams?fileChooserParams){if(mUMA?! =?null){
mUMA. onReceiveValue (nulo);
}
mUMA?=?filePathCallback;
Intent?takePictureIntent?=?new?Intent(MediaStore.ACTION_IMAGE_CAPTURE);if( takePictureIntent .resolveActivity(MainActivity.=?null){
Archivo?photoFile?=?null;try{
photoFile?=?mCM); catch (IOException?ex){
Log.e(TAG, ?" ¿Imagen?archivo?creación?failed",?ex);
}if(photoFile?! =? null ){
mCM?=?" archivo:"?+?photoFile.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,?Uri.fromFile(photoFile))
}el
se{
takePictureIntent?=?null;
}
}
Intent?contentSelectionIntent?=?new?Intent(Intent. ACTION_GET_CONTENT);
contentSelectionIntent.contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("image/*");
Intent[]? intentArray;if(takePictureIntent?=?null){
intentArray?=?new?Intent[]{takePictureIntent};
}else{
intentArray? =?new?Intent[0];
}
Intent.ChooserIntent = nuevo Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent .EXTRA_INTENT ,?contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, ?" Image?Chooser");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,?intentArray);
startActivityForResult(chooserIntent,?FCR);return?true;
}
}
});
}
El proyecto Os-FileUp en Github proporciona algunos métodos. webView.setWebChromeClient(new?WebChromeClient(){/For?Android?.
public?void?openFileChooser(ValueCallback mUM?=? uploadMsg; Intent?i?=?new?Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType ("imagen/*"); MainActivity.this.startActivityForResult(Intent.createChooser(i, "File?Chooser"),?FCR) ; }//?For El método anterior no es compatible con la versión ?Android?.. +El método anterior no es compatible con la versión, en este caso usamos el siguiente método public?void?openFileChooser(ValueCallback?uploadMsg,?String?acceptType){ mUM? =?uploadMsg; Intent?i?=?new?Intent(Intent.ACTION_GET_ CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); MainActivity.this.startActivityForResult( MainActivity.this.p> Intent.createChooser(i, ?" ¿Archivo? Navegador"), FCR); }/For?.1+ public?void?openFileChooser(ValueCallback mUM?=?uploadMsg; Intent?i?=?new?Intent(Intent.ACTION_GET_CONTENT); p> p> i.Add categoría(Intent.CATEGORY_OPENABLE); i.setType("image/*"); MainActivity.this.startActivityForResult(Intent. createChooser( i,? "Selector de archivos"),?MainActivity.FCR); }/Aplicable a Android?. public?boolean?onShowFileChooser( WebView?webView,?ValueCallback WebChromeClient.FileChooserParams?fileChooserParams){if(mUMA?! =?null){ mUMA. onReceiveValue (nulo); } mUMA?=?filePathCallback; Intent?takePictureIntent?=?new?Intent(MediaStore.ACTION_IMAGE_CAPTURE);if( takePictureIntent .resolveActivity(MainActivity.=?null){ Archivo?photoFile?=?null;try{ photoFile?=?mCM); catch (IOException?ex){ Log.e(TAG, ?" ¿Imagen?archivo?creación?failed",?ex); }if(photoFile?! =? null ){ mCM?=?" archivo:"?+?photoFile.getAbsolutePath(); takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,?Uri.fromFile(photoFile)) }el se{ takePictureIntent?=?null; } } Intent?contentSelectionIntent?=?new?Intent(Intent. ACTION_GET_CONTENT); contentSelectionIntent.contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE); contentSelectionIntent.setType("image/*"); Intent[]? intentArray;if(takePictureIntent?=?null){ intentArray?=?new?Intent[]{takePictureIntent}; }else{ intentArray? =?new?Intent[0]; } Intent.ChooserIntent = nuevo Intent(Intent.ACTION_CHOOSER); chooserIntent.putExtra(Intent .EXTRA_INTENT ,?contentSelectionIntent); chooserIntent.putExtra(Intent.EXTRA_TITLE, ?" Image?Chooser"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS,?intentArray); startActivityForResult(chooserIntent,?FCR);return?true; } } }); }