title: android BroadcastReceiver called twice
body: <p>i am working on chat project</p>
  
  <p>what i did here is service with the connection staff and i set a broadcast receiver to get the data from the service</p>
  
  <p>this is the receiver code</p>
  
  <pre><code>mMessageReceiver = new BroadcastReceiver() {
          @Override
          public void onReceive(Context context, Intent intent) {
              try {
                  final String code = intent.getExtras().get("code").toString();
                  final JSONObject Message = new JSONObject(intent.getExtras().get("msg").toString());
                  runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
                          Log.d("test","test");
                      }
                  });
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          }
      };
  
      LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver,new IntentFilter("data"));
  </code></pre>
  
  <p>the problem is when i close the activity the code inside runOnUiThread called more than one time </p>
  
  <p>if i close the activity and open it it called 2 times if i did it again it called 3 times and so on</p>