title: Kotlin LocalBroadcastManager not working after call to display values on UI
body: <p>I have an android application I am working on in which I am making API request with Volley, after making the API call, I get a bunch of JSON objects returned. I now saved the values into a default values. after saving, I now tried displaying the values into my ui elements but everything is blank and does noy show the values. My codes are highlighted below</p>
  
  <pre><code>fun loginUser(context: Context, email: String, password: String, completion: (Boolean) -&gt; Unit): Unit {
  
          val jsonBody = JSONObject()
          jsonBody.put("email", email)
          jsonBody.put("password", password)
          val requestBody = jsonBody.toString()
  
          val loginRequest = object : JsonObjectRequest(Method.POST, URL_LOGIN, null, Response.Listener {response -&gt;
  
              try {
                  userEmail = response.getString("user")
                  authToken = response.getString("token")
                  isLoggedIn = true
                  completion(true)
              } catch (e: JSONException) {
                  Log.d("JSON", "EXC:" + e.localizedMessage)
                  completion(false)
              }
          }, Response.ErrorListener { error -&gt;
              Log.d("ERROR", "Could not login user: $error")
              completion(false)
  
          }) {
              override fun getBodyContentType(): String {
                  return "application/json; charset=utf-8"
              }
              override fun getBody(): ByteArray {
                  return requestBody.toByteArray()
              }
          }
          Volley.newRequestQueue(context).add(loginRequest)
      }
  
  fun findUserByEmail(context: Context, completion: (Boolean) -&gt; Unit): Unit {
          val finUserByEmailRequest = object : JsonObjectRequest(Method.GET, "$URL_GET_USER$userEmail", null, Response.Listener {response -&gt;
              try {
                  UserDataService.name = response.getString("name")
                  UserDataService.email = response.getString("email")
                  UserDataService.avatarName = response.getString("avatarName")
                  UserDataService.avatarColor = response.getString("avatarColor")
                  UserDataService.id = response.getString("_id")
                  val userDataChanaged = Intent(BROADCAST_USER_DATA_CHANGED)
                  LocalBroadcastManager.getInstance(context).sendBroadcast(userDataChanaged)
                  completion(true)
              } catch (e: JSONException) {
                  Log.d("JSON", "EXC:" + e.localizedMessage)
                  completion(false)
              }
          }, Response.ErrorListener { error -&gt;
              Log.d("ERROR", "Could not find user: $error")
              completion(false)
  
          }) {
              override fun getBodyContentType(): String {
                  return "application/json; charset=utf-8"
              }
              override fun getHeaders(): MutableMap&lt;String, String&gt; {
                  val headers = HashMap&lt;String, String&gt;()
                  headers["Authorization"] = "Bearer $authToken"
                  return headers
              }
          }
          Volley.newRequestQueue(context).add(finUserByEmailRequest)
      }
  </code></pre>
  
  <p>my MainActivity</p>
  
  <pre><code>override fun onCreate(savedInstanceState: Bundle?) {
          super.onCreate(savedInstanceState)
          setContentView(R.layout.activity_main)
          setSupportActionBar(toolbar)
          val toggle = ActionBarDrawerToggle(
                  this, drawer_layout, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close)
          drawer_layout.addDrawerListener(toggle)
          toggle.syncState()
     LocalBroadcastManager.getInstance(this).registerReceiver(userDataChangeReceiver, IntentFilter(BROADCAST_USER_DATA_CHANGED))
      }
  
      private val userDataChangeReceiver = object : BroadcastReceiver() {
          override fun onReceive(contect: Context?, intent: Intent?) {
              if (AuthService.isLoggedIn) {
                  userNameNavHeader.text = UserDataService.name
                  userEmailNavHeader.text = UserDataService.email
  
                  val resourceId = resources.getIdentifier(UserDataService.avatarName, "drawable", packageName)
                  userImageNavHeader.setImageResource(resourceId)
                  userImageNavHeader.setBackgroundColor(UserDataService.returnAvatarColor(UserDataService.avatarColor))
                  loginBtnNavHeader.text = "Logout"
              }
          }
      }
  </code></pre>
  
  <p>Where loginUser method gets called</p>
  
  <pre><code>fun loginLoginBtnClicked(view: View): Unit {
  
          val email = loginEmailTxt.text.toString()
          val password = loginPasswordTxt.text.toString()
  
          AuthService.loginUser(this, email, password) {success -&gt;
              if (success) {
                  AuthService.findUserByEmail(this) {fsuccess -&gt;
                      if (fsuccess) {
                          finish()
                      }
                  }
              }
  
          }
      }
  </code></pre>