I haven't seen any cases like this. I have an activity which is initiated from a button on a dialog. I need to get a variable from this activity, close it, and pass it back to the dialog. What would be my approach?
 class ColorPickDialog(val activity: Activity, color: Int, val callback: (color: Int) -> Unit) {
lateinit var savedColorsButton: Button
val currentColorHsv = FloatArray(3)
init {
    Color.colorToHSV(color, currentColorHsv)
    val view = activity.layoutInflater.inflate(R.layout.d_colorpicker, null).apply {
        savedColorsButton = findViewById(R.id.saved_colours_button)
    savedColorsButton.setOnClickListener{
        val intent = Intent(this.activity.applicationContext, DisplayColorsActivity::class.java)
        intent.putExtra("SettingState", true)
        this.activity.applicationContext.startActivity(intent)
    }
 }
This is the activity that the dialog opens.
 public class DisplayColorsActivity extends Activity {
 public void displayColors() {
    ArrayList<ColourRGB> coloursList = colourStorage.getColours();
    LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        btn = (Button) findViewById(R.id.select_color_btn);
        if (getIntent().getExtras() != null && getIntent().getExtras().getBoolean("SettingState")) {
            btn.setVisibility(View.VISIBLE);
        }
        else {
            btn.setVisibility(View.INVISIBLE);
            Log.v("Status+", "INot there" );
        }
   } 
    public void selectButtonClicked(View view){
    finish();
    }
 }
I need to pass a variable from the DisplayColorsActivity back to the ColorPick dialog, maybe in the selectButtonClicked fuction, (which takes you back to the dialog using a button) Please note the first snippet is in Kotlin, the second in Java
 
     
    