本文整理汇总了Java中android.webkit.WebChromeClient.FileChooserParams方法的典型用法代码示例。如果您正苦于以下问题:Java WebChromeClient.FileChooserParams方法的具体用法?Java WebChromeClient.FileChooserParams怎么用?Java WebChromeClient.FileChooserParams使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.WebChromeClient
的用法示例。
在下文中一共展示了WebChromeClient.FileChooserParams方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onShowFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
public boolean onShowFileChooser(WebView view, ValueCallback<Uri[]> filePath, WebChromeClient.FileChooserParams fileChooserParams) {
// Double check that we don't have any existing callbacks
if (mFilePathCallback != null) {
mFilePathCallback.onReceiveValue(null);
}
mFilePathCallback = filePath;
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
if (takePictureIntent.resolveActivity(getPackageManager()) != null) {
// Create the File where the photo should go
File photoFile = null;
try {
photoFile = createImageFile();
takePictureIntent.putExtra("PhotoPath", mCameraPhotoPath);
} catch (IOException ex) {
// Error occurred while creating the File
Log.e(TAG, "Unable to create Image File", ex);
}
// Continue only if the File was successfully created
if (photoFile != null) {
mCameraPhotoPath = "file:" + photoFile.getAbsolutePath();
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,
Uri.fromFile(photoFile));
} else {
takePictureIntent = null;
}
}
Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
contentSelectionIntent.setType("*/*");
Intent[] intentArray;
if (takePictureIntent != null) {
intentArray = new Intent[]{takePictureIntent};
} else {
intentArray = new Intent[0];
}
Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
chooserIntent.putExtra(Intent.EXTRA_TITLE, "File Chooser");
chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentArray);
startActivityForResult(chooserIntent, INPUT_FILE_REQUEST_CODE);
return true;
}
示例2: onShowFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {
mBrowserController.showFileChooser(filePathCallback);
return true;
}
示例3: showFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
@Override
public void showFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
setFilePathCallbacks(filePathCallback);
String[] acceptTypes = new String[0];
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
acceptTypes = fileChooserParams.getAcceptTypes();
}
dealOpenFileChooser(acceptTypes.length > 0 ? acceptTypes[0] : "");
}
示例4: onShowFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView,
ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {
openFileChooser(value -> {
if (value == null) {
filePathCallback.onReceiveValue(null);
} else {
filePathCallback.onReceiveValue(new Uri[]{value});
}
}, fileChooserParams.getAcceptTypes());
return true;
}
示例5: onShowFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
WebChromeClient.FileChooserParams fileChooserParams) {
mUIController.showFileChooser(filePathCallback);
return true;
}
示例6: setFileChooserParams
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
public Builder setFileChooserParams(WebChromeClient.FileChooserParams fileChooserParams) {
mFileChooserParams = fileChooserParams;
return this;
}
示例7: openFileInput
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
private boolean openFileInput(ValueCallback<Uri> uriCallback, ValueCallback<Uri[]> arrayCallback, WebChromeClient.FileChooserParams fileChooserParams, boolean allowMultiple) {
if ((activity==null)&&(fragment==null))
throw new NullPointerException("Must set an activity or a fragment!");
assert activity != null;
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.READ_EXTERNAL_STORAGE)!=PackageManager.PERMISSION_GRANTED) {
if (activity!=null) {
ActivityCompat.requestPermissions(activity, new String[] {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
}, PERMISSION_REQUEST);
} else {
fragment.requestPermissions(new String[] {
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_EXTERNAL_STORAGE
}, PERMISSION_REQUEST);
}
return false;
}
if (filePathCallback!=null) {
filePathCallback.onReceiveValue(new Uri[]{});
filePathCallback = null;
}
if (this.uriCallback!=null) {
this.uriCallback.onReceiveValue(null);
this.uriCallback = null;
}
Intent intent= new Intent();
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.addCategory(Intent.CATEGORY_DEFAULT);
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("*/*");
if (Build.VERSION.SDK_INT>=21) {
if (fileChooserParams.getAcceptTypes()!=null)
intent.putExtra(Intent.EXTRA_MIME_TYPES, fileChooserParams.getAcceptTypes());
}
if (allowMultiple) {
if (Build.VERSION.SDK_INT >= 18) {
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
}
}
if ((arrayCallback!=null) && (fileChooserParams!=null)) {
this.filePathCallback = arrayCallback;
this.uriCallback = null;
} else if (uriCallback!=null) {
this.filePathCallback = null;
this.uriCallback = uriCallback;
}
String title = getResources().getString(R.string.file_picker);
if (Build.VERSION.SDK_INT>=21) {
try {
title = fileChooserParams.getTitle().toString();
} catch (Exception e) {
Log.e(TAG, e.getMessage());
}
}
if (activity!=null)
activity.startActivityForResult(Intent.createChooser(intent, title), REQUEST_FILE);
else if (fragment!=null)
fragment.startActivityForResult(Intent.createChooser(intent, title), REQUEST_FILE);
return true;
}
示例8: onShowFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams) {
mUploadCallbackAboveL = filePathCallback;
openImageChooserActivity();
return true;
}
示例9: showFileChooser
import android.webkit.WebChromeClient; //导入方法依赖的package包/类
void showFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams);