Java Code Examples for android.webkit.JavascriptInterface
The following examples show how to use
android.webkit.JavascriptInterface.
These examples are extracted from open source projects.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source Project: pe-protector-moe Author: ProtectorMoe File: MapPathHtml.java License: GNU General Public License v3.0 | 6 votes |
@JavascriptInterface public void onFinish(String name, String obj) { name = name.replace(" ", ""); // 检测是否有重复的 List<MapConfigBean> list = LitePal.select("*") .where("name=?", name) .find(MapConfigBean.class); for (MapConfigBean b : list) { b.delete(); } MapConfigBean bean = new MapConfigBean(); bean.name = name; bean.data = obj; bean.save(); callBack.onFinish(null); }
Example #2
Source Project: VideoOS-Android-SDK Author: VideoOS File: JsBridge.java License: GNU General Public License v3.0 | 6 votes |
@Deprecated @JavascriptInterface public void detectPaymentMethod(String jsParams) { VenvyLog.i("支付宝==" + jsParams); try { JSONObject json = new JSONObject(jsParams); JSONObject msg = json.optJSONObject("msg"); JSONObject data = msg.optJSONObject("data"); boolean result = goPay(data.optString("url")); String jsData = result ? "true" : "fasle"; callJsFunction(jsData, jsParams); } catch (Exception e) { e.printStackTrace(); } }
Example #3
Source Project: Focus Author: ihewro File: MJavascriptInterface.java License: GNU General Public License v3.0 | 6 votes |
@android.webkit.JavascriptInterface public void openUrl(final String url) { new MaterialDialog.Builder(activity) .title("即将前往") .content("点击「确定」将会访问该链接地址") .positiveText("确定") .negativeText("取消") .onPositive(new MaterialDialog.SingleButtonCallback() { @Override public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) { WebViewUtil.openLink(url, (Activity) activity); } }) .show(); }
Example #4
Source Project: alpha-wallet-android Author: AlphaWallet File: SignCallbackJSInterface.java License: MIT License | 6 votes |
@JavascriptInterface public void signTransaction( int callbackId, String recipient, String value, String nonce, String gasLimit, String gasPrice, String payload) { if (value.equals("undefined")) value = "0"; if (gasPrice == null) gasPrice = "0"; Web3Transaction transaction = new Web3Transaction( TextUtils.isEmpty(recipient) ? Address.EMPTY : new Address(recipient), null, Hex.hexToBigInteger(value), Hex.hexToBigInteger(gasPrice, BigInteger.ZERO), Hex.hexToBigInteger(gasLimit, BigInteger.ZERO), Hex.hexToLong(nonce, -1), payload, callbackId); webView.post(() -> onSignTransactionListener.onSignTransaction(transaction, getUrl())); }
Example #5
Source Project: PoupoLayer Author: MrCodeSniper File: PopWebViewService.java License: MIT License | 6 votes |
/** * 提供隐藏webview弹窗的服务 from native */ @JavascriptInterface public void hidePopLayer() { mWebView.post(new Runnable() { @Override public void run() { mWebView.setVisibility(View.GONE); PopManager.getInstance(mWebView.getContext()).onPopDimiss(); mWebView.stopLoading(); mWebView.clearHistory(); mWebView.clearCache(true); mWebView.loadUrl("about:blank"); mWebView.pauseTimers(); mWebView = null; } }); }
Example #6
Source Project: TelePlus-Android Author: TelePlusDev File: WebviewActivity.java License: GNU General Public License v2.0 | 6 votes |
@JavascriptInterface public void postEvent(final String eventName, final String eventData) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { if (getParentActivity() == null) { return; } if (BuildVars.LOGS_ENABLED) { FileLog.d(eventName); } switch (eventName) { case "share_game": currentMessageObject.messageOwner.with_my_score = false; break; case "share_score": currentMessageObject.messageOwner.with_my_score = true; break; } showDialog(ShareAlert.createShareAlert(getParentActivity(), currentMessageObject, null, false, linkToCopy, false)); } }); }
Example #7
Source Project: WanAndroid Author: chejdj File: SonicJavaScriptInterface.java License: MIT License | 6 votes |
@JavascriptInterface public void getDiffData2(final String jsCallbackFunc) { if (null != sessionClient) { sessionClient.getDiffData(new SonicDiffDataCallback() { @Override public void callback(final String resultData) { Runnable callbackRunnable = new Runnable() { @Override public void run() { String jsCode = "javascript:" + jsCallbackFunc + "('"+ toJsString(resultData) + "')"; sessionClient.getWebView().loadUrl(jsCode); } }; if (Looper.getMainLooper() == Looper.myLooper()) { callbackRunnable.run(); } else { new Handler(Looper.getMainLooper()).post(callbackRunnable); } } }); } }
Example #8
Source Project: VideoOS-Android-SDK Author: VideoOS File: JsBridge.java License: GNU General Public License v3.0 | 6 votes |
@JavascriptInterface public void setUserInfo(String jsParams) { VenvyLog.i("---userInfo--" + jsParams); try { JSONObject json = new JSONObject(jsParams); JSONObject user = json.optJSONObject("msg"); PlatformUserInfo platformUserInfo = new PlatformUserInfo(); platformUserInfo.setPhoneNum(user.optString("phone")); platformUserInfo.setUserToken(user.optString("token")); platformUserInfo.setUserName(user.optString("userName")); platformUserInfo.setNickName(user.optString("nickName")); platformUserInfo.setUid(user.optString("uid")); if (mPlatformLoginInterface != null) { mPlatformLoginInterface.userLogined(platformUserInfo); } //todo } catch (JSONException e) { } }
Example #9
Source Project: TelePlus-Android Author: TelePlusDev File: PaymentFormActivity.java License: GNU General Public License v2.0 | 6 votes |
@JavascriptInterface public void postEvent(final String eventName, final String eventData) { AndroidUtilities.runOnUIThread(() -> { if (getParentActivity() == null) { return; } if (eventName.equals("payment_form_submit")) { try { JSONObject jsonObject = new JSONObject(eventData); JSONObject response = jsonObject.getJSONObject("credentials"); paymentJson = response.toString(); cardName = jsonObject.getString("title"); } catch (Throwable e) { paymentJson = eventData; FileLog.e(e); } goToNextStep(); } }); }
Example #10
Source Project: TelePlus-Android Author: TelePlusDev File: EmbedBottomSheet.java License: GNU General Public License v2.0 | 6 votes |
@JavascriptInterface public void postEvent(final String eventName, final String eventData) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { switch (eventName) { case "loaded": progressBar.setVisibility(View.INVISIBLE); progressBarBlackBackground.setVisibility(View.INVISIBLE); pipButton.setEnabled(true); pipButton.setAlpha(1.0f); showOrHideYoutubeLogo(false); break; } } }); }
Example #11
Source Project: tysq-android Author: tysqapp File: TyJavaScriptInterface.java License: GNU General Public License v3.0 | 6 votes |
/** * 与js交互时用到的方法,在js里直接调用 */ @JavascriptInterface public void fromHtml(final String type, final String json) { Log.i(TAG, "fromHtml: [type: " + type + "; json:" + json + "]"); switch (type) { case Constant.HtmlType.OPEN_NEW_LINK: OpenNewLink openNewLink = mGson.fromJson(json, OpenNewLink.class); if (openNewLink.isNeedLogin()) { if (UserCache.isEmpty()) { LoginActivity.startActivity(mContext.get(), null); return; } } String navigationLink = openNewLink.getNavigationLink(); TyUtils.handleWebViewLink(mContext.get(), navigationLink); break; } }
Example #12
Source Project: amazon-sumerian-arcore-starter-app Author: aws-samples File: SumerianConnector.java License: Apache License 2.0 | 6 votes |
@JavascriptInterface public void registerAnchor(final String requestId, final float[] matrix) { if (requestId == null || matrix == null) { return; } mSurfaceView.queueEvent(new Runnable() { @Override public void run() { Pose anchorPose = Pose.makeTranslation(matrix[12], matrix[13], matrix[14]); Anchor anchor = mSession.createAnchor(anchorPose); final String scriptString = "ARCoreBridge.registerAnchorResponse('" + requestId + "', '" + String.valueOf(anchor.hashCode()) + "');"; evaluateWebViewJavascript(scriptString); } }); }
Example #13
Source Project: Web3View Author: trustwallet File: SignCallbackJSInterface.java License: GNU General Public License v3.0 | 6 votes |
@JavascriptInterface public void signTransaction( int callbackId, String recipient, String value, String nonce, String gasLimit, String gasPrice, String payload) { Transaction transaction = new Transaction( TextUtils.isEmpty(recipient) ? Address.EMPTY : new Address(recipient), null, Hex.hexToBigInteger(value), Hex.hexToBigInteger(gasPrice, BigInteger.ZERO), Hex.hexToLong(gasLimit, 0), Hex.hexToLong(nonce, -1), payload, callbackId); onSignTransactionListener.onSignTransaction(transaction); }
Example #14
Source Project: carstream-android-auto Author: thekirankumar File: JavascriptCallback.java License: Apache License 2.0 | 5 votes |
@JavascriptInterface public void onVideoDiscovered() { handler.post(new Runnable() { @Override public void run() { callbacks.onVideoElementDiscovered(); } }); }
Example #15
Source Project: pe-protector-moe Author: ProtectorMoe File: TaskManagerHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public String onPathDel(String taskName) { List<MapConfigBean> list = LitePal .where("name=?", taskName) .limit(1) .find(MapConfigBean.class); for (MapConfigBean bean : list) { bean.delete(); } return onRefresh(); }
Example #16
Source Project: pe-protector-moe Author: ProtectorMoe File: TaskManagerHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void onPathEdit(String taskName) { Intent intent = new Intent(App.getContext(), HtmlActivity.class); intent.putExtra("type", HtmlActivity.HTML_MAP); intent.putExtra("name", taskName); intent.putExtra("config", ""); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); App.getContext().startActivity(intent); }
Example #17
Source Project: pe-protector-moe Author: ProtectorMoe File: TaskManagerHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void onAddPath() { Intent intent = new Intent(App.getContext(), HtmlActivity.class); intent.putExtra("type", HtmlActivity.HTML_MAP); intent.putExtra("name", ""); intent.putExtra("config", ""); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); App.getContext().startActivity(intent); }
Example #18
Source Project: VideoOS-Android-SDK Author: VideoOS File: JsBridge.java License: GNU General Public License v3.0 | 5 votes |
/*** * 写入本地数据 * @param jsonParams */ @JavascriptInterface public void setStorageData(String jsonParams) { try { JSONObject json = new JSONObject(jsonParams); JSONObject msgObj = json.optJSONObject("msg"); String key = msgObj.optString("key"); String value = msgObj.optString("value"); VenvyPreferenceHelper.putString(mContext, TextUtils.isEmpty(mDeveloperUserId) ? "" : mDeveloperUserId, key, value); } catch (JSONException e) { } }
Example #19
Source Project: pe-protector-moe Author: ProtectorMoe File: TaskManagerHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public boolean upLoad(String uploadData) { UpLoadDataBean bean = JSON.parseObject(uploadData, UpLoadDataBean.class); bean.username = Config.username; bean.uid = Integer.valueOf(Config.userId); bean.path = getConfig(bean.config); new Thread(() -> { Requests requests = new Requests.Builder() .url("http://cloud.protector.moe/config/paths/") .json(JSON.toJSONString(bean)) .build() .execute(); Log.i(TAG, "上传文件" + requests.status); Looper.prepare(); if (requests.status == 201) { new SweetAlertDialog(this.activity, SweetAlertDialog.SUCCESS_TYPE) .setTitleText("在线配置") .setContentText("上传成功") .setConfirmText("确定") .setConfirmClickListener(SweetAlertDialog::cancel) .show(); } else { new SweetAlertDialog(this.activity, SweetAlertDialog.ERROR_TYPE) .setTitleText("在线配置") .setContentText("上传失败") .setCancelText("确定") .setCancelClickListener(SweetAlertDialog::cancel) .show(); } Looper.loop(); }).start(); return true; }
Example #20
Source Project: pe-protector-moe Author: ProtectorMoe File: TaskAddHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void onFinish(String obj) { Log.i(TAG, "[任务] 用户请求添加任务" + obj); TaskManager manager = TaskManager.getInstance(); manager.addTask(obj); callBack.onFinish(null); }
Example #21
Source Project: pe-protector-moe Author: ProtectorMoe File: PathDownloadHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void download(String data) { DownloadPathBean pathBean = JSON.parseObject(data, DownloadPathBean.class); List<MapConfigBean> list = LitePal .where("name=?", pathBean.title) .find(MapConfigBean.class); for (MapConfigBean l : list) { l.delete(); } MapConfigBean bean = new MapConfigBean(); bean.name = pathBean.title; bean.data = pathBean.path_pe.replace("\\", ""); bean.save(); }
Example #22
Source Project: Focus Author: ihewro File: MJavascriptInterface.java License: GNU General Public License v3.0 | 5 votes |
@android.webkit.JavascriptInterface public void longClickImage(String img) { ALog.d("长按图片" +img); //显示下拉底部弹窗 new XPopup.Builder(activity) .asCustom(new ImageManagePopupView(activity,img,null)) .show(); }
Example #23
Source Project: alpha-wallet-android Author: AlphaWallet File: TokenScriptCallbackInterface.java License: MIT License | 5 votes |
@JavascriptInterface public void setValues(String jsonValuesFromTokenView) { Map<String, String> updates; try { updates = new Gson().fromJson(jsonValuesFromTokenView, new TypeToken<HashMap<String, String>>() {}.getType()); } catch (Exception e) { updates = new HashMap<>(); } onSetValuesListener.setValues(updates); }
Example #24
Source Project: pe-protector-moe Author: ProtectorMoe File: SettingHtml.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void onFinish(String data) { Log.d(TAG, "收到设置:" + data); Setting setting = Setting.getInstance(); setting.settingBean = JSON.parseObject(data, SettingBean.class); setting.save(); callBack.onFinish(null); }
Example #25
Source Project: VideoOS-Android-SDK Author: VideoOS File: JsBridge.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void removeObserver(String type, String jsFunction) { if (jsMap.containsKey(type)) { List<String> temp = jsMap.get(type); if (temp.contains(jsFunction)) { temp.remove(jsFunction); } } }
Example #26
Source Project: GotoBrowser Author: antest1 File: KcsInterface.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void kcs_axios_error(String error) { activity.runOnUiThread(() -> { String text = String.format(Locale.US, "[Error] %s", error); ((TextView) activity.findViewById(R.id.kc_error_text)).setText(text); }); }
Example #27
Source Project: Focus Author: ihewro File: MJavascriptInterface.java License: GNU General Public License v3.0 | 5 votes |
@android.webkit.JavascriptInterface public void longClickImage(String img) { ALog.d("长按图片" +img); //显示下拉底部弹窗 new XPopup.Builder(activity) .asCustom(new ImageManagePopupView(activity,img,null)) .show(); }
Example #28
Source Project: RichWebList Author: 756718646 File: JavaScriptLog.java License: Apache License 2.0 | 5 votes |
/** * 点击图片 */ @JavascriptInterface public void clickImage(String src){ LogUtil.v(TAG,"webview点击图片:"+src); if (clickImageCallBack!=null){ clickImageCallBack.clickImage(src); } }
Example #29
Source Project: xGetter Author: KhunHtetzNaing File: GDrive2020.java License: Apache License 2.0 | 5 votes |
@SuppressWarnings("unused") @JavascriptInterface public void error() { new Handler(Looper.getMainLooper()).post(new Runnable() { @Override public void run() { destroyWebView(); out(null); } }); }
Example #30
Source Project: VideoOS-Android-SDK Author: VideoOS File: JsBridge.java License: GNU General Public License v3.0 | 5 votes |
@JavascriptInterface public void setConfig(String jsParams) { try { JSONObject json = new JSONObject(jsParams); JSONObject payStatus = json.optJSONObject("msg"); payDisabled = payStatus.optBoolean("payDisabled"); //todo } catch (JSONException e) { } }