android.webkit.ValueCallback#onReceiveValue ( )源码实例Demo

下面列出了android.webkit.ValueCallback#onReceiveValue ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AgentWeb   文件: AgentWebConfig.java
public static void removeSessionCookies(ValueCallback<Boolean> callback) {
    if (callback == null) {
        callback = getDefaultIgnoreCallback();
    }
    if (CookieManager.getInstance() == null) {
        callback.onReceiveValue(new Boolean(false));
        return;
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().removeSessionCookie();
        toSyncCookies();
        callback.onReceiveValue(new Boolean(true));
        return;
    }
    CookieManager.getInstance().removeSessionCookies(callback);
    toSyncCookies();
}
 
源代码2 项目: AgentWeb   文件: DefaultChromeClient.java
private void createAndOpenCommonFileChooser(ValueCallback valueCallback, String mimeType) {
	Activity mActivity = this.mActivityWeakReference.get();
	if (mActivity == null || mActivity.isFinishing()) {
		valueCallback.onReceiveValue(new Object());
		return;
	}
	AgentWebUtils.showFileChooserCompat(mActivity,
			mWebView,
			null,
			null,
			this.mPermissionInterceptor,
			valueCallback,
			mimeType,
			null
	);
}
 
@Override
public void evaluateJavascript(String js, ValueCallback<String> callback) {

    if(callback == null)
        webView.evaluateJavascript(js,null);

     final ValueCallback<String> proxyCallback = callback;
     com.tencent.smtt.sdk.ValueCallback mCallback = new com.tencent.smtt.sdk.ValueCallback() {
        @Override
        public void onReceiveValue(Object o) {
            if(o instanceof String)
                proxyCallback.onReceiveValue((String) o);
        }
    };
    webView.evaluateJavascript(js,mCallback);
}
 
源代码4 项目: unity-ads-android   文件: WebPlayerView.java
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
	Boolean returnValue = false;

	if (shouldCallSuper("onShowFileChooser")) {
		returnValue = super.onShowFileChooser(webView, filePathCallback, fileChooserParams);
	}
	if (shouldSendEvent("onShowFileChooser")) {
		WebViewApp.getCurrentApp().sendEvent(WebViewEventCategory.WEBPLAYER, WebPlayerEvent.SHOW_FILE_CHOOSER, viewId);
	}
	if (hasReturnValue("onShowFileChooser")) {
		returnValue = getReturnValue("onShowFileChooser", java.lang.Boolean.class, true);
		if (returnValue) {
			filePathCallback.onReceiveValue(null);
		}
	}

	return returnValue;
}
 
源代码5 项目: Ninja   文件: BrowserActivity.java
@Override
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    // Because Activity launchMode is singleInstance,
    // so we can not get result from onActivityResult when Android 4.X,
    // what a pity
    //
    // this.uploadMsg = uploadMsg;
    // Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    // intent.addCategory(Intent.CATEGORY_OPENABLE);
    // intent.setType("*/*");
    // startActivityForResult(Intent.createChooser(intent, getString(R.string.main_file_chooser)), IntentUnit.REQUEST_FILE_16);
    uploadMsg.onReceiveValue(null);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setCancelable(true);

    FrameLayout layout = (FrameLayout) getLayoutInflater().inflate(R.layout.dialog_desc, null, false);
    TextView textView = (TextView) layout.findViewById(R.id.dialog_desc);
    textView.setText(R.string.dialog_content_upload);

    builder.setView(layout);
    builder.create().show();
}
 
/**
* Notify the host application that an SSL error occurred while loading a
* resource. The host application must call either callback.onReceiveValue(true)
* or callback.onReceiveValue(false). Note that the decision may be
* retained for use in response to future SSL errors. The default behavior
* is to pop up a dialog.
*/
@Override
public void onReceivedSslError(XWalkView view, ValueCallback<Boolean> callback, SslError error) {
    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            callback.onReceiveValue(true);
        } else {
            // debug = false
            callback.onReceiveValue(false);
        }
    } catch (PackageManager.NameNotFoundException e) {
        // When it doubt, lock it out!
        callback.onReceiveValue(false);
    }
}
 
源代码7 项目: appcan-android   文件: CBrowserMainFrame7.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public boolean onShowFileChooser(WebView mWebView, ValueCallback<Uri[]> filePathCallback, WebChromeClient.FileChooserParams fileChooserParams)
{
    ValueCallback<Uri[]> uploadMessage = ((EBrowserActivity) mContext).getUploadMessage();
    if (uploadMessage != null) {
        uploadMessage.onReceiveValue(null);
        uploadMessage = null;
    }

    uploadMessage = filePathCallback;
    ((EBrowserActivity)mContext).setUploadMessage(uploadMessage);
    Intent intent = fileChooserParams.createIntent();
    try
    {
        ((EBrowserActivity)mContext).startActivityForResult(intent, REQUEST_SELECT_FILE);
    } catch (ActivityNotFoundException e)
    {
        uploadMessage = null;
        Toast.makeText(mContext, "Cannot Open File Chooser", Toast.LENGTH_LONG).show();
        return false;
    }
    return true;
}
 
源代码8 项目: AgentWeb   文件: AgentWebConfig.java
public static void removeAllCookies(@Nullable ValueCallback<Boolean> callback) {
    if (callback == null) {
        callback = getDefaultIgnoreCallback();
    }
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        CookieManager.getInstance().removeAllCookie();
        toSyncCookies();
        callback.onReceiveValue(!CookieManager.getInstance().hasCookies());
        return;
    }
    CookieManager.getInstance().removeAllCookies(callback);
    toSyncCookies();
}
 
public boolean onShowFileChooser(
        WebView webView, ValueCallback<Uri[]> filePathCallback,
        FileChooserParams fileChooserParams) {

    String acceptTypes[] = fileChooserParams.getAcceptTypes();

    String acceptType = "";
    for (int i = 0; i < acceptTypes.length; ++i) {
        if (acceptTypes[i] != null && acceptTypes[i].length() != 0)
            acceptType += acceptTypes[i] + ";";
    }
    if (acceptType.length() == 0)
        acceptType = "*/*";

    final ValueCallback<Uri[]> finalFilePathCallback = filePathCallback;

    ValueCallback<Uri> vc = new ValueCallback<Uri>() {

        @Override
        public void onReceiveValue(Uri value) {

            Uri[] result;
            if (value != null)
                result = new Uri[]{value};
            else
                result = null;

            finalFilePathCallback.onReceiveValue(result);

        }
    };

    openFileChooser(vc, acceptType, "filesystem");

    return true;
}
 
源代码10 项目: 920-text-editor-v2   文件: EditAreaView.java
@JavascriptInterface
public void returnValue(long id, String value) {
    ValueCallback<String> callback = callbackMap.get(id);
    if (callback != null) {
        callback.onReceiveValue(value);
        callbackMap.remove(id);
    }
}
 
源代码11 项目: IoTgo_Android_App   文件: CordovaActivity.java
/**
 * Called when an activity you launched exits, giving you the requestCode you started it with,
 * the resultCode it returned, and any additional data from it.
 *
 * @param requestCode       The request code originally supplied to startActivityForResult(),
 *                          allowing you to identify who this result came from.
 * @param resultCode        The integer result code returned by the child activity through its setResult().
 * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    LOG.d(TAG, "Incoming Result");
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d(TAG, "Request code = " + requestCode);
    if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
    	ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        Log.d(TAG, "did we get here?");
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
        Log.d(TAG, "result = " + result);
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    CordovaPlugin callback = this.activityResultCallback;
    if(callback == null && initCallbackClass != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
        callback = this.activityResultCallback;
    }
    if(callback != null) {
        LOG.d(TAG, "We have a callback to send this result to");
        callback.onActivityResult(requestCode, resultCode, intent);
    }
}
 
源代码12 项目: reader   文件: CordovaActivity.java
/**
 * Called when an activity you launched exits, giving you the requestCode you started it with,
 * the resultCode it returned, and any additional data from it.
 *
 * @param requestCode       The request code originally supplied to startActivityForResult(),
 *                          allowing you to identify who this result came from.
 * @param resultCode        The integer result code returned by the child activity through its setResult().
 * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    LOG.d(TAG, "Incoming Result");
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d(TAG, "Request code = " + requestCode);
    if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
    	ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        Log.d(TAG, "did we get here?");
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
        Log.d(TAG, "result = " + result);
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    CordovaPlugin callback = this.activityResultCallback;
    if(callback == null && initCallbackClass != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
        callback = this.activityResultCallback;
    }
    if(callback != null) {
        LOG.d(TAG, "We have a callback to send this result to");
        callback.onActivityResult(requestCode, resultCode, intent);
    }
}
 
源代码13 项目: reader   文件: CordovaActivity.java
/**
 * Called when an activity you launched exits, giving you the requestCode you started it with,
 * the resultCode it returned, and any additional data from it.
 *
 * @param requestCode       The request code originally supplied to startActivityForResult(),
 *                          allowing you to identify who this result came from.
 * @param resultCode        The integer result code returned by the child activity through its setResult().
 * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
 */
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
    LOG.d(TAG, "Incoming Result");
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d(TAG, "Request code = " + requestCode);
    if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
    	ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        Log.d(TAG, "did we get here?");
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
        Log.d(TAG, "result = " + result);
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    CordovaPlugin callback = this.activityResultCallback;
    if(callback == null && initCallbackClass != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
        callback = this.activityResultCallback;
    }
    if(callback != null) {
        LOG.d(TAG, "We have a callback to send this result to");
        callback.onActivityResult(requestCode, resultCode, intent);
    }
}
 
源代码14 项目: appcan-android   文件: CBrowserMainFrame.java
public WebViewSdkCompat.ValueCallback<Uri> getCompatCallback(final ValueCallback<Uri> uploadMsg){
    return new WebViewSdkCompat.ValueCallback<Uri>() {
        @Override
        public void onReceiveValue(Uri uri) {
            uploadMsg.onReceiveValue(uri);
        }
    };
}
 
源代码15 项目: appcan-android   文件: CBrowserMainFrame.java
public WebViewSdkCompat.ValueCallback<Uri> getCompatCallback(final ValueCallback<Uri> uploadMsg){
    return new WebViewSdkCompat.ValueCallback<Uri>() {
        @Override
        public void onReceiveValue(Uri uri) {
            uploadMsg.onReceiveValue(uri);
        }
    };
}
 
源代码16 项目: phonegapbootcampsite   文件: CordovaActivity.java
@Override
    /**
     * Called when an activity you launched exits, giving you the requestCode you started it with,
     * the resultCode it returned, and any additional data from it.
     *
     * @param requestCode       The request code originally supplied to startActivityForResult(),
     *                          allowing you to identify who this result came from.
     * @param resultCode        The integer result code returned by the child activity through its setResult().
     * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
     */
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        LOG.d(TAG, "Incoming Result");
        super.onActivityResult(requestCode, resultCode, intent);
        Log.d(TAG, "Request code = " + requestCode);
        if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
        	ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
            Log.d(TAG, "did we get here?");
            if (null == mUploadMessage)
                return;
            Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
            Log.d(TAG, "result = " + result);
//            Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
//            Log.d(TAG, "result = " + filepath);
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
        CordovaPlugin callback = this.activityResultCallback;
        if(callback == null && initCallbackClass != null) {
            // The application was restarted, but had defined an initial callback
            // before being shut down.
            this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
            callback = this.activityResultCallback;
        }
        if(callback != null) {
            LOG.d(TAG, "We have a callback to send this result to");
            callback.onActivityResult(requestCode, resultCode, intent);
        }
    }
 
@Override
    /**
     * Called when an activity you launched exits, giving you the requestCode you started it with,
     * the resultCode it returned, and any additional data from it.
     *
     * @param requestCode       The request code originally supplied to startActivityForResult(),
     *                          allowing you to identify who this result came from.
     * @param resultCode        The integer result code returned by the child activity through its setResult().
     * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
     */
    protected void onActivityResult(int requestCode, int resultCode, Intent intent) {
        LOG.d(TAG, "Incoming Result");
        super.onActivityResult(requestCode, resultCode, intent);
        Log.d(TAG, "Request code = " + requestCode);
        if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
        	ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
            Log.d(TAG, "did we get here?");
            if (null == mUploadMessage)
                return;
            Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
            Log.d(TAG, "result = " + result);
//            Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
//            Log.d(TAG, "result = " + filepath);
            mUploadMessage.onReceiveValue(result);
            mUploadMessage = null;
        }
        CordovaPlugin callback = this.activityResultCallback;
        if(callback == null && initCallbackClass != null) {
            // The application was restarted, but had defined an initial callback
            // before being shut down.
            this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
            callback = this.activityResultCallback;
        }
        if(callback != null) {
            LOG.d(TAG, "We have a callback to send this result to");
            callback.onActivityResult(requestCode, resultCode, intent);
        }
    }
 
源代码18 项目: VBrowser-Android   文件: MainActivity.java
@Override
public void onReceivedSslError(XWalkView view, ValueCallback<Boolean> callback, SslError error) {
    callback.onReceiveValue(true);
}
 
源代码19 项目: AgentWeb   文件: AgentWebUtils.java
static boolean showFileChooserCompat(Activity activity,
	                                     WebView webView,
	                                     ValueCallback<Uri[]> valueCallbacks,
	                                     WebChromeClient.FileChooserParams fileChooserParams,
	                                     PermissionInterceptor permissionInterceptor,
	                                     ValueCallback valueCallback,
	                                     String mimeType,
	                                     Handler.Callback jsChannelCallback
	) {
		try {
			Class<?> clz = Class.forName("com.just.agentweb.filechooser.FileChooser");
			Object mFileChooser$Builder = clz.getDeclaredMethod("newBuilder",
					Activity.class, WebView.class)
					.invoke(null, activity, webView);
			clz = mFileChooser$Builder.getClass();
			Method mMethod = null;
			if (valueCallbacks != null) {
				mMethod = clz.getDeclaredMethod("setUriValueCallbacks", ValueCallback.class);
				mMethod.setAccessible(true);
				mMethod.invoke(mFileChooser$Builder, valueCallbacks);
			}
			if (fileChooserParams != null) {
				mMethod = clz.getDeclaredMethod("setFileChooserParams", WebChromeClient.FileChooserParams.class);
				mMethod.setAccessible(true);
				mMethod.invoke(mFileChooser$Builder, fileChooserParams);
			}
			if (valueCallback != null) {
				mMethod = clz.getDeclaredMethod("setUriValueCallback", ValueCallback.class);
				mMethod.setAccessible(true);
				mMethod.invoke(mFileChooser$Builder, valueCallback);
			}
			if (!TextUtils.isEmpty(mimeType)) {
//                LogUtils.i(TAG, Arrays.toString(clz.getDeclaredMethods()));
				mMethod = clz.getDeclaredMethod("setAcceptType", String.class);
				mMethod.setAccessible(true);
				mMethod.invoke(mFileChooser$Builder, mimeType);
			}
			if (jsChannelCallback != null) {
				mMethod = clz.getDeclaredMethod("setJsChannelCallback", Handler.Callback.class);
				mMethod.setAccessible(true);
				mMethod.invoke(mFileChooser$Builder, jsChannelCallback);
			}
			mMethod = clz.getDeclaredMethod("setPermissionInterceptor", PermissionInterceptor.class);
			mMethod.setAccessible(true);
			mMethod.invoke(mFileChooser$Builder, permissionInterceptor);
			mMethod = clz.getDeclaredMethod("build");
			mMethod.setAccessible(true);
			Object mFileChooser = mMethod.invoke(mFileChooser$Builder);
			mMethod = mFileChooser.getClass().getDeclaredMethod("openFileChooser");
			mMethod.setAccessible(true);
			mMethod.invoke(mFileChooser);
		} catch (Throwable throwable) {
			if (LogUtils.isDebug()) {
				throwable.printStackTrace();
			}
			if (throwable instanceof ClassNotFoundException) {
				LogUtils.e(TAG, "Please check whether compile'com.just.agentweb:filechooser:x.x.x' dependency was added.");
			}
			if (valueCallbacks != null) {
				LogUtils.i(TAG, "onReceiveValue empty");
				return false;
			}
			if (valueCallback != null) {
				valueCallback.onReceiveValue(null);
			}
		}
		return true;
	}
 
源代码20 项目: Cornowser   文件: CornUIClient.java
@Override
public boolean onCreateWindowRequested(XWalkView view, InitiateBy initiator, ValueCallback<XWalkView> callback) {
    CornBrowser.getTabSwitcher().addTab(new Tab());
    callback.onReceiveValue(CornBrowser.getTabSwitcher().getCurrentTab().getWebView());
    return true;
}
 
 方法所在类
 同类方法