当前位置: 首页>>代码示例>>Java>>正文


Java ValueCallback类代码示例

本文整理汇总了Java中android.webkit.ValueCallback的典型用法代码示例。如果您正苦于以下问题:Java ValueCallback类的具体用法?Java ValueCallback怎么用?Java ValueCallback使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ValueCallback类属于android.webkit包,在下文中一共展示了ValueCallback类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onPageFinished

import android.webkit.ValueCallback; //导入依赖的package包/类
@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);
    }

}
 
开发者ID:ashutoshbsathe,项目名称:COEP-Moodle-via-Webview,代码行数:30,代码来源:Moodle.java

示例2: linkBridge

import android.webkit.ValueCallback; //导入依赖的package包/类
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));" +
      "}" +
    ")");
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:24,代码来源:ReactWebViewManager.java

示例3: openFileChooserImplForAndroid5

import android.webkit.ValueCallback; //导入依赖的package包/类
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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:MyWebChromeClient.java

示例4: onPageFinished

import android.webkit.ValueCallback; //导入依赖的package包/类
@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");
                }
            });
        }
    }
}
 
开发者ID:mgilangjanuar,项目名称:GoSCELE,代码行数:18,代码来源:WebViewClientUtil.java

示例5: openFileChooserAboveL

import android.webkit.ValueCallback; //导入依赖的package包/类
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;

    }
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:24,代码来源:DefaultChromeClient.java

示例6: callJsDescription

import android.webkit.ValueCallback; //导入依赖的package包/类
/**
 * 调用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;
}
 
开发者ID:AlpacaNotSheep,项目名称:hybrid,代码行数:27,代码来源:BaseWebActivity.java

示例7: evaluateJavascript

import android.webkit.ValueCallback; //导入依赖的package包/类
@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");
    }
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:11,代码来源:SystemWebViewEngine.java

示例8: openFileChooser

import android.webkit.ValueCallback; //导入依赖的package包/类
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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:8,代码来源:BrowserActivity.java

示例9: AnnouncementsScraper

import android.webkit.ValueCallback; //导入依赖的package包/类
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);
                        }
                    }
                });
            }
        }
    };
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:37,代码来源:AnnouncementsScraper.java

示例10: onPageFinished

import android.webkit.ValueCallback; //导入依赖的package包/类
@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);
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:11,代码来源:InjectableWebClient.java

示例11: openFileChooser

import android.webkit.ValueCallback; //导入依赖的package包/类
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);
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:9,代码来源:BetBrowserFragment.java

示例12: openFileChooserImpl

import android.webkit.ValueCallback; //导入依赖的package包/类
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);
}
 
开发者ID:lai233333,项目名称:MyDemo,代码行数:8,代码来源:MyWebChromeClient.java

示例13: setAttribute

import android.webkit.ValueCallback; //导入依赖的package包/类
/**
 * 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) {
        }
    });
}
 
开发者ID:TheAndroidMaster,项目名称:Blackboard,代码行数:14,代码来源:Blackboard.java

示例14: clearCookiesAsync

import android.webkit.ValueCallback; //导入依赖的package包/类
private void clearCookiesAsync(final Callback callback) {
  getCookieManager().removeAllCookies(
      new ValueCallback<Boolean>() {
        @Override
        public void onReceiveValue(Boolean value) {
          mCookieSaver.onCookiesModified();
          callback.invoke(value);
        }
      });
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:11,代码来源:ForwardingCookieHandler.java

示例15: onClick

import android.webkit.ValueCallback; //导入依赖的package包/类
@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;
    }

}
 
开发者ID:Justson,项目名称:AgentWeb,代码行数:31,代码来源:JSAgentWebFragment.java


注:本文中的android.webkit.ValueCallback类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。