Home  >  Q&A  >  body text

java - 如何在Fragment中调用Activity的onNewIntent?

如题 我怎么在Fragment中调用Activity中的OnNewInetent?

PHP中文网PHP中文网2741 days ago566

reply all(3)I'll reply

  • 阿神

    阿神2017-04-18 10:52:32

    Add a public method in Activity, call the onNewIntent method in this method, and then call the method exposed by Activity through getActivity in Fragment. I'm a little curious, why are you actively calling the onNewIntent method?

    reply
    0
  • 怪我咯

    怪我咯2017-04-18 10:52:32

    En’s idea is wrong. This method doesn’t work because there are 4 Fragments in my mainActivity (FragmentA FragmentB FragmentC FragmentD). Among them, there are other ActivityA that need to jump to FragmentA. My previous idea was to jump directly to MainActivy and then from MainActivity. Control add or replace FragmentA, but there is a problem. There is a rollback stack in MainActivity (because the startup mode in MainActivity is Stand mode). So I set the startup mode in MainActivity to SingleTask. Now something goes wrong again. ActivityA cannot jump. In MainActivity, I re-created the OnnewIntent() method to solve the problem. However, FragmentC needs the data in A to update the view (FragmentC is a pie chart and cannot be updated in real time). I wonder if I can re-create the OnNewIntent() method. The view update method is done in this method. .

    reply
    0
  • PHP中文网

    PHP中文网2017-04-18 10:52:32

    Your difficulty is that you need to update the data while the Activity jumps. The two can be processed separately. Use the regular one for Activity jump. Data updates can be monitored using third-party libraries such as EventBus.

    reply
    0
  • Cancelreply