search

Home  >  Q&A  >  body text

Android 当activity A 启动了activityB C D之后再返回A

并且销毁BCD还要刷新A内的数据,应该要用starActivityForResult么?单例模式能行么?

高洛峰高洛峰2769 days ago498

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:48:15

    If A will only be returned in B, then use startActivityForResultstartActivityForResult

    如果在B, C, D都有可能返回A, 同时不会有同时两个A的话, 使用SingleTask模式, 直接在B/C/D中直接启动A, 根据singleTask的特性就会自动销毁A之后启动的Activity, 返回数据可以直接通过intent传数据, 然后再onNewIntent()

    If it is possible to return A in B, C, and D, and there will not be two A at the same time, use SingleTask mode to directly start A in B/C/D. According to the characteristics of singleTask, A will be automatically destroyed. For the started Activity, the returned data can be transferred directly through the intent, and then the data can be received in onNewIntent() to refresh the view🎜

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-04-17 17:48:15

    Direct call back to A can be achieved by clearing the top of the stack or directly finishing when switching between B, C, and D.
    Refreshing the page when returning to A can be achieved through the onResume method or broadcast.

    reply
    0
  • Cancelreply