回到另一个活动中的活动中已打开的对话框

问题描述 投票:0回答:2

[我有两个活动,第一个活动在按下时具有fab,它是打开的>一个带有按钮的对话框,当我按下该按钮时,它将带我到另一个具有>映射的活动来保存字符串并返回到第一个活动中的对话框,以在文本>视图中设置该对话框中的值]

我该怎么做?

android
2个回答
0
投票

当您在第二个活动中onbackpress时,将intent中的数据发送到第一个活动中,然后再次在onresumeonstart功能构建对话框中发送。


0
投票

要向活动发送数据活动,只需使用意图。

一个(带有对话框)->地图->一个

在地图活动中,

@Override
public void onBackPressed() {
    super.onBackPressed();
    Intent intent = new Intent(getApplicationContext(), a.class);
    intent.putExtra("INFO", yourData);
}

和活动中,

@Override
protected void onResume() {
    super.onResume();
    Intent intent = getIntent(); 

    // receive the value by getStringExtra() method 
    // and key must be same which is send by first activity 
    String str = intent.getStringExtra("INFO"); 
    dialogText.setText(str);   //setText in your dialog textView.
}
© www.soinside.com 2019 - 2024. All rights reserved.