title: Cordova #Intent-BroadcastReceiver
body: <p>First of all, I'm working with some specific API ( Grand Stream GXV3275 phone ) which requires that Intent - BroadcastReceiver combo breaker.</p>
  
  <p>When my device is on landscape orientation it works good so the problem came with Intent - BroadcastReceiver.</p>
  
  <p>So I need that IntentFilter to know my HOOKEVENT ans then receive it with that BroadcastReceiver.</p>
  
  <p>I just want to know why it doesn't even show the alert or don't work at all.
  Is that possible to deal with IntentFilter on CordovaPlugin? With BroadcastReceiver?</p>
  
  <p>I made some test on my CordovaActivity and HOOKEVENT ; updating a text-view.
  So I assume that's a problem with CordovaPlugin.</p>
  
  <p>I also tried to do: </p>
  
  <pre><code>CordovaActivity activity = (CordovaActivity) this.cordova.getActivity();
  activity.getJs(); 
  </code></pre>
  
  <p>Which normally allow me to get string that works on my activity but gave me NPE..</p>
  
  <p>public class Toast extends CordovaPlugin {</p>
  
  <pre><code>private String javascript = "";
  
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
      initHookEvent();
      switch (action) {
          case "reversed":
              reversedTest();
              return true;
      }
      return false;
  }
  
  private Activity getActivity() { return this.cordova.getActivity();}
  
  private void reversedTest(){
     Configuration configuration = getActivity().getResources().getConfiguration();
     if(configuration.orientation == Configuration.ORIENTATION_LANDSCAPE){
         webView.sendJavascript("javascript:document.getElementById(\"combi\").innerHTML=\"Landscape\";");
     }
     webView.sendJavascript(javascript);
  }
  
  public void initHookEvent() {
     IntentFilter filter = new IntentFilter("com.base.module.phone.HOOKEVENT");
     getActivity().registerReceiver(broadcastReceiver, filter);
  }
  
  public BroadcastReceiver broadcastReceiver = new BroadcastReceiver() {
     @Override
     public void onReceive(Context context, Intent intent) {
        webView.sendJavascript("javascript:alert(\"test\");");
        if (intent.getBooleanExtra("hookoff", false)){
           javascript = "javascript:document.getElementById(\"combi\").innerHTML=\"decroche\";";
        }
        else{
           javascript = "javascript:document.getElementById(\"combi\").innerHTML=\"raccroche\";";
        }
     }
  };
  </code></pre>