Call an activity method from a fragment

前端 未结 14 868
广开言路
广开言路 2020-11-22 09:08

Trying to call a method in my activity from a fragment. I want the fragment to give the method data and to get the data when the method return. I want to achieve similar to

14条回答
  •  生来不讨喜
    2020-11-22 09:27

    I have tried with all the methods shown in this thread and none worked for me, try this one. It worked for me.

    ((MainActivity) getContext().getApplicationContext()).Method();
    

提交回复
热议问题