Android ios only calls photography in webapp.
Happy work, many problems. (o()o)
The new problem of webapp is to solve a problem that the camera can not call the album directly when click ing on the uploaded picture. (What kind of operation is it?
I only remember that this property of capture can directly call camera, video and other functions, but we need to get rid of multiple which can be multi selected. The first attempt has failed, but this can be used in ios.
There's no way to do it. Ask the Barbary, the frenzy mode starts, and still can't find a solution. Hey hey hey
Here's an example of your favorite code
Front-end call method
Because in ios, you can support only calling the camera, so you can change the value of accept with app to open the camera directly.
1. before modification
<input type="file" capture="camera" ng-model="vm.avatarFile1" ngf-accept="'image/*'">
2. after revision
<input type="file" capture="camera" ng-model="vm.avatarFile1" ngf-accept="'bugdd/*'">
An Zhuoke code
The meaning of this code is probably to get the parameters in accept to determine whether they contain the parameters he needs. Call the camera method if it contains it, or the camera and album method if it does not.
@Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) { String[] acceptTypes = fileChooserParams.getAcceptTypes(); mOpenFileChooserCallBack.showFileChooserCallBack(filePathCallback, acceptTypes); return true; } public interface OpenFileChooserCallBack { void openFileChooserCallBack(ValueCallback<Uri> uploadMsg, String acceptType); void showFileChooserCallBack(ValueCallback<Uri[]> filePathCallback, String[] acceptTypes); } @Override public void showFileChooserCallBack(ValueCallback<Uri[]> filePathCallback, String[] acceptType) { mUploadMsg5Plus = filePathCallback; showOptions(acceptType[0]); } public void showOptions(String acceptType) { if (acceptType.indexOf("bugdd")) {//Determine whether this parameter exists in accept startCamera(); } else { AlertDialog.Builder alertDialog = new AlertDialog.Builder(this); alertDialog.setOnCancelListener(new ReOnCancelListener()); alertDialog.setItems(array.options, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { /** * Album */ if (which == 0) { startPicture(); } /** * Photograph */ if (which == 1) { //Start up camera startCamera(); } } }); alertDialog.show(); } } /** * Start Picture Selection */ private void startPicture() { if (!checkPermission(MyConstant.img_permissions, REQUEST_CODE_PICK_IMAGE_PER)) { return; } pick_imageIntent = ImageUtil.choosePicture(); startActivityForResult(pick_imageIntent, REQUEST_CODE_PICK_IMAGE); } /** * Open the camera and get the picture */ private void startCamera() { if (!this.checkPermission(MyConstant.photo_permissions, REQUEST_CODE_IMAGE_CAPTURE_PER)) { return; } image_captureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); //Judging whether there is a camera application if (image_captureIntent.resolveActivity(getPackageManager()) == null) { //No camera Toast.makeText(this, "Cannot turn on camera", Toast.LENGTH_SHORT).show(); return; } //Setting up compatibility configuration mainly considers Android N if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { //Application authority image_captureIntent.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); image_captureIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION); // } try { photoFile = createImageFile(); } catch (Exception ex) { ex.printStackTrace(); } if (photoFile != null) { contentUri = FileProvider.getUriForFile(this, "com.zrbx.yzs.fileProvider", photoFile); } image_captureIntent.putExtra(MediaStore.EXTRA_OUTPUT, contentUri); startActivityForResult(image_captureIntent, REQUEST_CODE_IMAGE_CAPTURE); }