将数据发送到旧活动

时间:2012-09-17 17:00:46

标签: android android-intent

我使用Flags Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP启动旧的Activity,但我无法使用putExtra向此活动发送字符串:

Intent intent = new Intent(INTENT_ActivityA);
intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtra("DATA", "OK");
startActivity(intent);
<{1}} onResume

中的

如何将数据发送到正在运行的Activity?

1 个答案:

答案 0 :(得分:8)

如果你覆盖onNewIntent,我认为你应该在其中包含你的数据。试试以下

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    intent.getStringExtra("DATA");
} 

希望它有所帮助!