use of android.webkit.JavascriptInterface in project ForPDA by RadiationX.
the class ThemeFragmentWeb method callbackUpdateHistoryHtml.
@JavascriptInterface
public void callbackUpdateHistoryHtml(String value) {
ThemePage themePage = history.get(history.size() - 1);
Log.d(LOG_TAG, "updateHistoryLastHtml " + themePage + " : " + currentPage);
themePage.setScrollY(webView.getScrollY());
themePage.setHtml(value);
}
use of android.webkit.JavascriptInterface in project fitpay-android-sdk by fitpay.
the class WebViewCommunicatorImpl method dispatchMessage.
@Override
@JavascriptInterface
public void dispatchMessage(String message) throws JSONException {
if (message == null) {
FPLog.w(WV_DATA, "\\Received\\: invalid message");
throw new IllegalArgumentException("invalid message");
}
JSONObject obj = new JSONObject(message);
String callBackId = obj.getString("callBackId");
if (callBackId == null) {
FPLog.w(WV_DATA, "\\Received\\: callBackId is missing in the message");
throw new IllegalArgumentException("callBackId is missing in the message");
}
String type = obj.getString("type");
if (type == null) {
FPLog.w(WV_DATA, "\\Received\\: type is missing in the message");
throw new IllegalArgumentException("type is missing in the message");
}
FPLog.i(WV_DATA, String.format(Locale.getDefault(), "\\Received\\: callbackId:%s type:%s", callBackId, type));
String dataStr = obj.has("data") ? obj.getString("data") : null;
RxBus.getInstance().post(new RtmMessage(callBackId, dataStr, type));
}
use of android.webkit.JavascriptInterface in project summer-android by cn-cerc.
the class JavaScriptProxy method list.
// 列出所有可用的服务
@JavascriptInterface
public String list() {
Map<String, String> items = new LinkedHashMap<>();
JSONObject json = new JSONObject();
try {
for (Class clazz : services.keySet()) {
String[] args = clazz.getName().split("\\.");
String temp = args[args.length - 1];
json.put(temp, services.get(clazz));
}
} catch (JSONException e) {
e.printStackTrace();
}
return json.toString();
}
use of android.webkit.JavascriptInterface in project summer-android by cn-cerc.
the class JavaScriptProxy method send.
// 调用指定的服务,须立即返回
@JavascriptInterface
public String send(String classCode, String dataIn) {
String function = null;
Class clazz = getClazz(classCode);
JavaScriptResult json = new JavaScriptResult();
JSONObject request = null;
try {
request = new JSONObject(dataIn);
if (request.has("_callback_")) {
function = request.getString("_callback_");
}
if (clazz != null) {
Object object = clazz.newInstance();
if (object instanceof JavaScriptService) {
JavaScriptService object1 = (JavaScriptService) object;
json.setData(object1.execute(this.owner, request));
json.setResult(true);
return json.toString();
} else {
json.setMessage("not support JavascriptInterface");
}
} else {
json.setMessage("当前版本不支持: " + classCode);
}
} catch (InstantiationException e) {
json.setMessage("InstantiationException");
} catch (IllegalAccessException e) {
json.setMessage("IllegalAccessException");
} catch (Exception e) {
json.setMessage(e.getMessage());
}
if (function != null && !"".equals(function)) {
MyApp.getInstance().executiveJS(function, json.toString());
}
return json.toString();
}
use of android.webkit.JavascriptInterface in project wigle-wifi-wardriving by wiglenet.
the class WiGLERegistrationInterface method registrationComplete.
/**
* update the users authentication preferences from JS running in the page
*
* @param userName
* @param userId
* @param token
*/
@JavascriptInterface
public void registrationComplete(final String userName, final String userId, final String token) {
MainActivity.info("Successful registration for " + userName + " auth ID: " + userId);
final SharedPreferences prefs = MainActivity.getMainActivity().getSharedPreferences(ListFragment.SHARED_PREFS, 0);
final SharedPreferences.Editor editor = prefs.edit();
editor.putString(ListFragment.PREF_USERNAME, userName);
editor.putString(ListFragment.PREF_AUTHNAME, userId);
editor.putBoolean(ListFragment.PREF_BE_ANONYMOUS, false);
editor.apply();
TokenAccess.setApiToken(prefs, token);
activity.finish();
}
Aggregations