I have been trying to figure out why the toast is not showing. from the code, the onReceive method does get executed and change the button color, but the Toast does not display. I dont know why.
client = new Client(
(publisher, topic, params) -> runOnUiThread(
() -> onReceive((Publisher) publisher, topic, params)
));
client.connectToServer("192.168.3.52",5050);
private void onReceive(Publisher publisher, String topic, Map<String, Object> params) {
sendBtn.setBackgroundColor(getColor(R.color.white));
Toast.makeText(MainActivity.this, "Hey", Toast.LENGTH_LONG).show();
}
Imports
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
Class name
public class MainActivity extends AppCompatActivity {