本文整理匯總了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);