Android Open Source - JSBridge Test A P I One






From Project

Back to project page JSBridge.

License

The source code is released under:

MIT License

If you think the Android project JSBridge listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.siva4u.jsbridge.example;
/*  w w  w. java  2  s .c  o m*/
import android.content.Context;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.Toast;

import com.siva4u.jsbridge.JSBridge;
import com.siva4u.jsbridge.JSBridgeAPIBase;

public class TestAPIOne extends JSBridgeAPIBase {

  public TestAPIOne(Context c, WebView view) {
    super(c, view);
  }

  @JavascriptInterface
  public void APIOne() {
    JSBridge.Log("TestAPIOne:APIOne: START");    
        Toast.makeText(webViewContext, "Hello....", Toast.LENGTH_SHORT).show();
  }
  
    @JavascriptInterface
    public void APITwo(String strParam) {
    JSBridge.Log("TestAPIOne:APITwo: START: "+strParam);    
        Toast.makeText(webViewContext, strParam, Toast.LENGTH_SHORT).show();
    }
    
    @JavascriptInterface
    public void APIThree(String strJson) {
    JSBridge.Log("TestAPIOne:APIThree: START: Str: "+strJson);
    JSBridge.Log("TestAPIOne:APIThree: START: Object: "+JSBridge.getJSONObject(strJson));
        Toast.makeText(webViewContext, strJson, Toast.LENGTH_SHORT).show();
    }
    
    @JavascriptInterface
    public String APIFour(String strJson) {
      JSBridge.Log("TestAPIOne:APIFour: START: Str: "+strJson);
      JSBridge.Log("TestAPIOne:APIFour: START: Object: "+JSBridge.getJSONObject(strJson));
        Toast.makeText(webViewContext, strJson, Toast.LENGTH_SHORT).show();
        return "Returned Value from APIFour...";
    }
    
    @JavascriptInterface
    public String APIFive(String strJson) {
      JSBridge.Log("TestAPIOne:APIFive: START: Str: "+strJson);
      JSBridge.Log("TestAPIOne:APIFive: START: Object: "+JSBridge.getJSONObject(strJson));
        Toast.makeText(webViewContext, strJson, Toast.LENGTH_SHORT).show();
        return "Returned JSON String:"+strJson;
    }

    @JavascriptInterface
    public void APISix(String strJson) {
      JSBridge.Log("TestAPIOne:APISix: START: Str: "+strJson);
      JSBridge.Log("TestAPIOne:APISix: START: Object: "+JSBridge.getJSONObject(strJson));
    Toast.makeText(webViewContext, strJson, Toast.LENGTH_SHORT).show();
        callCallback(strJson,strJson);
    }

    @JavascriptInterface
    public String APISeven(String strJson) {
      JSBridge.Log("TestAPIOne:APISeven: START: Str: "+strJson);
      JSBridge.Log("TestAPIOne:APISeven: START: Object: "+JSBridge.getJSONObject(strJson));
    Toast.makeText(webViewContext, strJson, Toast.LENGTH_SHORT).show();
        callCallback(strJson,strJson);
        return "Returned value from APISeven..."+strJson;
    }

}




Java Source Code List

com.siva4u.jsbridge.JSBridgeAPIBase.java
com.siva4u.jsbridge.JSBridgeCallback.java
com.siva4u.jsbridge.JSBridgeHandler.java
com.siva4u.jsbridge.JSBridgeInteface.java
com.siva4u.jsbridge.JSBridge.java
com.siva4u.jsbridge.example.TestAPIOne.java
com.siva4u.main.MainActivity.java