Code example for JSONObject

Methods: put, toString

0
    @Override 
    public void onButtonClick(DoorHanger dh, String tag) {
        if (tag.equals("disable")) {
            // To disable mixed content blocking, reload the page with a flag to load mixed content. 
            try { 
                JSONObject data = new JSONObject();
                data.put("allowMixedContent", true);
                GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", data.toString());
                GeckoAppShell.sendEventToGecko(e);
            } catch (JSONException e) {
                Log.e(LOGTAG, "Exception creating message to allow mixed content", e);
            } 
        } else if (tag.equals("enable")) {
            // To enable mixed content blocking, reload the page without any flags. 
            GeckoEvent e = GeckoEvent.createBroadcastEvent("Session:Reload", "");
            GeckoAppShell.sendEventToGecko(e);
        } 
 
        dismiss(); 
    }