java - 如何在Fragment中调用Activity的onNewIntent?
PHP中文网
PHP中文网 2017-04-18 10:50:32
0
3
612

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

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
阿神

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?

刘奇

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. .

洪涛

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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template