Java Code Examples for android.webkit.ValueCallback

The following are top voted examples for showing how to use android.webkit.ValueCallback. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: COEP-Moodle-via-Webview   File: Moodle.java   Source Code and License 8 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);

    final String password = profile.getString("password", null);
    final String username = profile.getString("username", null);
    if(profile.getString("username",null).equals("default") || profile.getString("password",null).equals("default"))
    {
        Toast.makeText(getApplicationContext(),"Enter your login details properly !",Toast.LENGTH_LONG).show();
        Intent log = new Intent(Moodle.this,LoginActivity.class);
        startActivity(log);
        return;
    }
    final String js = "javascript:" +
            "document.getElementById('password').value = '" + password + "';" +
            "document.getElementById('username').value = '" + username + "';" +
            "document.getElementById('loginbtn').click()";
    if (Build.VERSION.SDK_INT >= 19) {
        view.evaluateJavascript(js, new ValueCallback<String>() {
            @Override
            public void onReceiveValue(String s) {

            }
        });
    } else {
        view.loadUrl(js);
    }

}
 
Example 2
Project: RNLearn_Project1   File: ReactWebViewManager.java   Source Code and License 6 votes vote down vote up
public void linkBridge() {
  if (messagingEnabled) {
    if (ReactBuildConfig.DEBUG && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
      // See isNative in lodash
      String testPostMessageNative = "String(window.postMessage) === String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage')";
      evaluateJavascript(testPostMessageNative, new ValueCallback<String>() {
        @Override
        public void onReceiveValue(String value) {
          if (value.equals("true")) {
            FLog.w(ReactConstants.TAG, "Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined");
          }
        }
      });
    }

    loadUrl("javascript:(" +
      "window.originalPostMessage = window.postMessage," +
      "window.postMessage = function(data) {" +
        BRIDGE_NAME + ".postMessage(String(data));" +
      "}" +
    ")");
  }
}
 
Example 3
Project: GitHub   File: MyWebChromeClient.java   Source Code and License 6 votes vote down vote up
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMessageForAndroid5 = uploadMsg;
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("image/*");

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");

    mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5);
}
 
Example 4
Project: GoSCELE   File: WebViewClientUtil.java   Source Code and License 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.KITKAT)
@Override
public void onPageFinished(WebView view, String url) {
    super.onPageFinished(view, url);
    if (url.contains("login/")) {
        UserModel model = new UserModel().find().executeSingle();
        if (model != null) {
            webView.evaluateJavascript("(function() {document.getElementsByName('username')[0].value='" + model.username + "';document.getElementsByName('password')[0].value='" + model.password + "';document.getElementById('login').submit(); " +
                    "return { var1: \"variable1\", var2: \"variable2\" }; })();", new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String value) {
                    Log.d("authentication", "success");
                }
            });
        }
    }
}
 
Example 5
Project: AgentWeb   File: DefaultChromeClient.java   Source Code and License 6 votes vote down vote up
private boolean openFileChooserAboveL(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {


        LogUtils.i(TAG, "fileChooserParams:" + fileChooserParams.getAcceptTypes() + "  getTitle:" + fileChooserParams.getTitle() + " accept:" + Arrays.toString(fileChooserParams.getAcceptTypes()) + " length:" + fileChooserParams.getAcceptTypes().length + "  :" + fileChooserParams.isCaptureEnabled() + "  " + fileChooserParams.getFilenameHint() + "  intent:" + fileChooserParams.createIntent().toString()+"   mode:"+fileChooserParams.getMode());

        Activity mActivity = this.mActivityWeakReference.get();
        if (mActivity == null || mActivity.isFinishing()) {
            filePathCallback.onReceiveValue(new Uri[]{});
            return false;
        }
        IFileUploadChooser mIFileUploadChooser = this.mIFileUploadChooser;
        this.mIFileUploadChooser = mIFileUploadChooser = new FileUpLoadChooserImpl.Builder()
                .setWebView(webView)
                .setActivity(mActivity)
                .setUriValueCallbacks(filePathCallback)
                .setFileChooserParams(fileChooserParams)
                .setFileUploadMsgConfig(mChromeClientMsgCfg.getFileUploadMsgConfig())
                .setPermissionInterceptor(this.mPermissionInterceptor)
                .build();
        mIFileUploadChooser.openFileChooser();
        return true;

    }
 
Example 6
Project: hybrid   File: BaseWebActivity.java   Source Code and License 6 votes vote down vote up
/**
 * 调用js串的时候 引用此方法  例:document.querySelectorAll('*[name=description]')[0].getAttribute('content')
 *
 * @param funtionName
 *                  需要传递的JS串
 */
protected String callJsDescription(final String funtionName) {
    runOnUiThread(new Runnable() {

        @Override
        public void run() {
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                webView.evaluateJavascript(funtionName, new ValueCallback<String>() {
                    @Override
                    public void onReceiveValue(String value) {
                        Log.e("value", value);
                        content = value;
                    }
                });
            } else {
                webView.loadUrl(funtionName);
            }
        }
    });
    return content;
}
 
Example 7
Project: MyDemo   File: MyWebChromeClient.java   Source Code and License 6 votes vote down vote up
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMessageForAndroid5 = uploadMsg;
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("image/*");

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");

    mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5);
}
 
Example 8
Project: siiMobilityAppKit   File: SystemWebViewEngine.java   Source Code and License 5 votes vote down vote up
@Override
public void evaluateJavascript(String js, ValueCallback<String> callback) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(js, callback);
    }
    else
    {
        LOG.d(TAG, "This webview is using the old bridge");
    }
}
 
Example 9
Project: boohee_v5.6   File: BrowserActivity.java   Source Code and License 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    BrowserActivity.this.mUploadMessage = uploadMsg;
    Intent i = new Intent("android.intent.action.GET_CONTENT");
    i.addCategory("android.intent.category.OPENABLE");
    i.setType("image/*");
    BrowserActivity.this.startActivityForResult(Intent.createChooser(i, "File Chooser"), 1);
}
 
Example 10
Project: Blackboard   File: AnnouncementsScraper.java   Source Code and License 5 votes vote down vote up
public AnnouncementsScraper(Blackboard blackboard) {
    super(blackboard);
    handler = new Handler();
    runnable = new Runnable() {
        @Override
        public void run() {
            if (!isCancelled()) {
                getBlackboard().getHtmlContent("announcementList", new ValueCallback<String>() {
                    @Override
                    public void onReceiveValue(String s) {
                        JsonReader reader = new JsonReader(new StringReader(s));
                        reader.setLenient(true);

                        try {
                            if (reader.peek() != JsonToken.NULL) {
                                if (reader.peek() == JsonToken.STRING)
                                    onComplete(reader.nextString());
                            }
                        } catch (Exception ignored) {
                        }

                        try {
                            reader.close();
                        } catch (IOException ignored) {
                        }

                        if (!isComplete()) {
                            onError(false);
                            handler.postDelayed(runnable, 1000);
                        }
                    }
                });
            }
        }
    };
}
 
Example 11
Project: https-github.com-hyb1996-NoRootScriptDroid   File: InjectableWebClient.java   Source Code and License 5 votes vote down vote up
@Override
public void onPageFinished(WebView view, String url) {
    mWebView = view;
    setUpWebView(view);
    while (!mToInjectJavaScripts.isEmpty()) {
        Pair<String, ValueCallback<String>> pair = mToInjectJavaScripts.poll();
        inject(view, pair.first, pair.second);
    }
    super.onPageFinished(view, url);
}
 
Example 12
Project: GankReader   File: MyWebChromeClient.java   Source Code and License 5 votes vote down vote up
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMessageForAndroid5 = uploadMsg;
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("image/*");

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");

    mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5);
}
 
Example 13
Project: boohee_v5.6   File: BetBrowserFragment.java   Source Code and License 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    BetBrowserFragment.this.mUploadMessage = uploadMsg;
    Intent i = new Intent("android.intent.action.GET_CONTENT");
    i.addCategory("android.intent.category.OPENABLE");
    i.setType("image/*");
    BetBrowserFragment.this.startActivityForResult(Intent.createChooser(i, "File " +
            "Chooser"), 1);
}
 
Example 14
Project: MyDemo   File: MyWebChromeClient.java   Source Code and License 5 votes vote down vote up
private void openFileChooserImpl(ValueCallback<Uri> uploadMsg) {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("image/*");
    mActivity.startActivityForResult(Intent.createChooser(i, "文件选择"), FILECHOOSER_RESULTCODE);
}
 
Example 15
Project: Blackboard   File: Blackboard.java   Source Code and License 5 votes vote down vote up
/**
 * Sets an attribute of an element in the WebView
 * @param id the element to apply the attribute to
 * @param attribute the name of the attribute to change
 * @param value the value to change the attribute to
 */
public void setAttribute(String id, String attribute, String value) {
    webView.evaluateJavascript("(function(){document.getElementById('" + id + "')." + attribute + " = " + value + ";})();", new ValueCallback<String>() {
        @Override
        public void onReceiveValue(String s) {
        }
    });
}
 
Example 16
Project: RNLearn_Project1   File: ForwardingCookieHandler.java   Source Code and License 5 votes vote down vote up
private void clearCookiesAsync(final Callback callback) {
  getCookieManager().removeAllCookies(
      new ValueCallback<Boolean>() {
        @Override
        public void onReceiveValue(Boolean value) {
          mCookieSaver.onCookiesModified();
          callback.invoke(value);
        }
      });
}
 
Example 17
Project: AgentWeb   File: JSAgentWebFragment.java   Source Code and License 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.KITKAT)
@Override
public void onClick(View v) {


    switch (v.getId()){

        case R.id.callJsNoParamsButton:
            mAgentWeb.getJsEntraceAccess().quickCallJs("callByAndroid");
            break;

        case R.id.callJsOneParamsButton:
            mAgentWeb.getJsEntraceAccess().quickCallJs("callByAndroidParam","Hello ! Agentweb");
            break;

        case R.id.callJsMoreParamsButton:
            mAgentWeb.getJsEntraceAccess().quickCallJs("callByAndroidMoreParams", new ValueCallback<String>() {
                @Override
                public void onReceiveValue(String value) {
                    Log.i("Info","value:"+value);
                }
            },getJson(),"say:", " Hello! Agentweb");

            break;
        case R.id.jsJavaCommunicationButton:
            mAgentWeb.getJsEntraceAccess().quickCallJs("callByAndroidInteraction","你好Js");
            break;
    }

}
 
Example 18
Project: AgentWeb   File: BaseJsEntraceAccess.java   Source Code and License 5 votes vote down vote up
@Override
public void callJs(String js, final ValueCallback<String> callback) {

    LogUtils.i(TAG,"method callJs:"+js);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        this.evaluateJs(js, callback);
    } else {
        this.loadJs(js);
    }


}
 
Example 19
Project: Blackboard   File: UsernameScraper.java   Source Code and License 5 votes vote down vote up
public UsernameScraper(Blackboard blackboard) {
    super(blackboard);
    handler = new Handler();
    runnable = new Runnable() {
        @Override
        public void run() {
            if (!isCancelled()) {
                getBlackboard().getAttribute("global-nav-link", "innerText", new ValueCallback<String>() {
                    @Override
                    public void onReceiveValue(String s) {
                        JsonReader reader = new JsonReader(new StringReader(s));
                        reader.setLenient(true);

                        try {
                            if (reader.peek() != JsonToken.NULL) {
                                if (reader.peek() == JsonToken.STRING)
                                    onComplete(reader.nextString().replace("[0-9]", ""));
                            }
                        } catch (Exception ignored) {
                        }

                        try {
                            reader.close();
                        } catch (IOException ignored) {
                        }

                        if (!isComplete()) {
                            onError(false);
                            handler.postDelayed(runnable, 1000);
                        }
                    }
                });
            }
        }
    };
}
 
Example 20
Project: AgentWeb   File: BaseJsEntraceAccess.java   Source Code and License 5 votes vote down vote up
@Override
public void quickCallJs(String method, ValueCallback<String> callback,String... params) {

    StringBuilder sb=new StringBuilder();
    sb.append("javascript:"+method);
    if(params==null||params.length==0){
        sb.append("()");
    }else{
        sb.append("(").append(concat(params)).append(")");
    }


    callJs(sb.toString(),callback);

}
 
Example 21
Project: youkes_browser   File: LightningView.java   Source Code and License 5 votes vote down vote up
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
		WebChromeClient.FileChooserParams fileChooserParams) {
	mBrowserController.showFileChooser(filePathCallback);
	return true;
}
 
Example 22
Project: Xndroid   File: BrowserActivity.java   Source Code and License 5 votes vote down vote up
/**
 * opens a file chooser
 * param ValueCallback is the message from the WebView indicating a file chooser
 * should be opened
 */
@Override
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
    mUploadMessage = uploadMsg;
    Intent i = new Intent(Intent.ACTION_GET_CONTENT);
    i.addCategory(Intent.CATEGORY_OPENABLE);
    i.setType("*/*");
    startActivityForResult(Intent.createChooser(i, getString(R.string.title_file_chooser)), 1);
}
 
Example 23
Project: keemob   File: SystemWebViewEngine.java   Source Code and License 5 votes vote down vote up
@Override
public void evaluateJavascript(String js, ValueCallback<String> callback) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(js, callback);
    }
    else
    {
        LOG.d(TAG, "This webview is using the old bridge");
    }
}
 
Example 24
Project: AgentWeb   File: DefaultChromeClient.java   Source Code and License 5 votes vote down vote up
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
    LogUtils.i(TAG, "openFileChooser>=5.0");
    if (AgentWebUtils.isOverriedMethod(mWebChromeClient, "onShowFileChooser", ChromePath + ".onShowFileChooser", WebView.class, ValueCallback.class, FileChooserParams.class)) {

        return super.onShowFileChooser(webView, filePathCallback, fileChooserParams);
    }

    return openFileChooserAboveL(webView, filePathCallback, fileChooserParams);
}
 
Example 25
Project: XinFramework   File: CookiesHandler.java   Source Code and License 5 votes vote down vote up
private static ValueCallback<Boolean> getDefaultIgnoreCallback() {

        return new ValueCallback<Boolean>() {
            @Override
            public void onReceiveValue(Boolean ignore) {
                Log.i("removeExpiredCookies:" + ignore);
            }
        };
    }
 
Example 26
Project: AgentWeb   File: DefaultChromeClient.java   Source Code and License 5 votes vote down vote up
public void openFileChooser(ValueCallback valueCallback, String acceptType) {
    Log.i(TAG, "openFileChooser>3.0");

    if (AgentWebUtils.isOverriedMethod(mWebChromeClient, "openFileChooser", ChromePath + ".openFileChooser", ValueCallback.class, String.class)) {
        super.openFileChooser(valueCallback, acceptType);
        return;
    }
    createAndOpenCommonFileLoader(valueCallback, acceptType);
}
 
Example 27
Project: AgentWeb   File: FileUpLoadChooserImpl.java   Source Code and License 5 votes vote down vote up
public Builder setUriValueCallback(ValueCallback<Uri> uriValueCallback) {
    mUriValueCallback = uriValueCallback;
    isL = false;
    jsChannel = false;
    mUriValueCallbacks = null;
    mJsChannelCallback = null;
    return this;
}
 
Example 28
Project: AgentWeb   File: FileUpLoadChooserImpl.java   Source Code and License 5 votes vote down vote up
public Builder setUriValueCallbacks(ValueCallback<Uri[]> uriValueCallbacks) {
    mUriValueCallbacks = uriValueCallbacks;
    isL = true;
    mUriValueCallback = null;
    mJsChannelCallback = null;
    jsChannel = false;
    return this;
}
 
Example 29
Project: AgentWeb   File: JsEntraceAccessImpl.java   Source Code and License 5 votes vote down vote up
@Override
public void callJs(String params, final ValueCallback<String> callback) {
    if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
        callSafeCallJs(params, callback);
        return;
    }

    super.callJs(params,callback);

}
 
Example 30
Project: AgentWebX5   File: BaseJsEntraceAccess.java   Source Code and License 5 votes vote down vote up
private void evaluateJs(String js, final ValueCallback<String>callback){

        mWebView.evaluateJavascript(js, new com.tencent.smtt.sdk.ValueCallback<String>() {
            @Override
            public void onReceiveValue(String value) {
                if (callback != null)
                    callback.onReceiveValue(value);
            }
        });
    }
 
Example 31
Project: RNLearn_Project1   File: ForwardingCookieHandler.java   Source Code and License 5 votes vote down vote up
private void clearCookiesAsync(final Callback callback) {
  getCookieManager().removeAllCookies(
      new ValueCallback<Boolean>() {
        @Override
        public void onReceiveValue(Boolean value) {
          mCookieSaver.onCookiesModified();
          callback.invoke(value);
        }
      });
}
 
Example 32
Project: DinningShare   File: SystemWebViewEngine.java   Source Code and License 5 votes vote down vote up
@Override
public void evaluateJavascript(String js, ValueCallback<String> callback) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        webView.evaluateJavascript(js, callback);
    }
    else
    {
        LOG.d(TAG, "This webview is using the old bridge");
    }
}
 
Example 33
Project: browser   File: LightningView.java   Source Code and License 5 votes vote down vote up
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback,
		WebChromeClient.FileChooserParams fileChooserParams) {
	mBrowserController.showFileChooser(filePathCallback);
	return true;
}
 
Example 34
Project: FicsaveMiddleware   File: MainActivity.java   Source Code and License 5 votes vote down vote up
public void runJSonPage(String url) {
    Log.d("ficsaveM/runJSCalled", url + " " + ficUrl);
    // Check if not loading the download URL and some fanfic url is there to download
    if (!url.contains(getString(R.string.ficsave_download_url))) {

        if (!ficUrl.isEmpty() && !Patterns.WEB_URL.matcher(ficUrl).matches()) {
            Toast.makeText(
                    getApplicationContext(),
                    R.string.invalid_fic_url + " " + ficUrl,
                    Toast.LENGTH_LONG
            ).show();
        }

        // Get javascript to run on page
        final String jsString = getJsScript();

        // Execute Javascript on a new thread 2 second after page load
        Log.d("ficsaveM/JSrun", "Start");

        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                mWebview.evaluateJavascript(jsString, new ValueCallback<String>() {
                    @Override
                    public void onReceiveValue(String value) {
                        Log.d("ficsaveM/JSrun", "Success, Value: " + value);
                        trackJsRunSuccess(value);

                        // empty the fanfic url so it won't get downloaded again somehow
                        ficUrl = "";
                    }
                });
            }
        }, 2000);
    }
}
 
Example 35
Project: browser   File: BrowserActivity.java   Source Code and License 5 votes vote down vote up
@Override
/**
 * opens a file chooser
 * param ValueCallback is the message from the WebView indicating a file chooser
 * should be opened
 */
public void openFileChooser(ValueCallback<Uri> uploadMsg) {
	mUploadMessage = uploadMsg;
	Intent i = new Intent(Intent.ACTION_GET_CONTENT);
	i.addCategory(Intent.CATEGORY_OPENABLE);
	i.setType("*/*");
	startActivityForResult(Intent.createChooser(i, getString(R.string.title_file_chooser)), 1);
}
 
Example 36
Project: boohee_v5.6   File: BetBrowserFragment.java   Source Code and License 5 votes vote down vote up
public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String
        capture) {
    BetBrowserFragment.this.mUploadMessage = uploadMsg;
    Intent i = new Intent("android.intent.action.GET_CONTENT");
    i.addCategory("android.intent.category.OPENABLE");
    i.setType("image/*");
    BetBrowserFragment.this.startActivityForResult(Intent.createChooser(i, "File " +
            "Chooser"), 1);
}
 
Example 37
Project: CustomActionWebView   File: APIWebViewActivity.java   Source Code and License 5 votes vote down vote up
/**
 * 执行网页中的js方法
 */
void callJsFunction() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        mWebView.evaluateJavascript("javascript:callJS()", new ValueCallback<String>() {
            @Override
            public void onReceiveValue(String value) {
                //接受返回值
            }
        });
    } else {
        mWebView.loadUrl("javascript:callJS()");
    }
}
 
Example 38
Project: quickhybrid-android   File: FileChooser.java   Source Code and License 5 votes vote down vote up
@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] : "");
}
 
Example 39
Project: EasyReader   File: MyWebChromeClient.java   Source Code and License 5 votes vote down vote up
private void openFileChooserImplForAndroid5(ValueCallback<Uri[]> uploadMsg) {
    mUploadMessageForAndroid5 = uploadMsg;
    Intent contentSelectionIntent = new Intent(Intent.ACTION_GET_CONTENT);
    contentSelectionIntent.addCategory(Intent.CATEGORY_OPENABLE);
    contentSelectionIntent.setType("image/*");

    Intent chooserIntent = new Intent(Intent.ACTION_CHOOSER);
    chooserIntent.putExtra(Intent.EXTRA_INTENT, contentSelectionIntent);
    chooserIntent.putExtra(Intent.EXTRA_TITLE, "图片选择");

    mActivity.startActivityForResult(chooserIntent, FILECHOOSER_RESULTCODE_FOR_ANDROID_5);
}
 
Example 40
Project: cordova-plugin-x5-webview   File: X5WebViewEngine.java   Source Code and License 5 votes vote down vote up
@Override
public void evaluateJavascript(String js, ValueCallback<String> callback) {
    if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
        // For override to type casting by Jeremy
        webView.evaluateJavascript(js, (com.tencent.smtt.sdk.ValueCallback) callback);
    }
    else
    {
        LOG.d(TAG, "This webview is using the old bridge");
    }
}