Android Build a Weather App Hooking Up the Model to the View I'm Feeling Refreshed

Ikuyasu Usui
Ikuyasu Usui
43,574 Points

The app hangs up second time it gets refreshed when implemented with setOnClickListener.

I implemented onClick functionality using setOnClickListener like the below, but it allows me to refresh one time, but when I try again, the app hangs up, becomes non-responsive.

 private ImageView refreshImageView;
...
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getForecast(latitude, longitude);

    refreshImageView = findViewById(R.id.refreshImage);
    refreshImageView.setOnClickListener(new OnClickListener() {
      @Override
      public void onClick(View view) {
        refreshOnClick(view);
      }
    });

When using android:onClick="refreshOnClick", it works. I can refresh many times. I don't know why this happens.

Ikuyasu Usui
Ikuyasu Usui
43,574 Points

Looking at logcat, I get

"2019-01-15 11:25:04.768 1961-1984/system_process I/GnssLocationProvider: WakeLock released by handleMessage(REPORT_SV_STATUS, 0, com.android.server.location.GnssLocationProvider$SvStatusInfo@e2bf1ec) "

many many times with verbose mode.