Skip to content Skip to sidebar Skip to footer

Call A Fragment's Method From Parent Activity

Hi everyone, [Introduction] I have created a ScreenSlide Pager (extending FragmentActivity) to handle 4 fragments in MainActivity. I also have a service, handling a bluetooth comm

Solution 1:

If you want to call a fragment method from activity just do the following :

Fragment  fragment = getSupportFragmentManager().findFragmentById(R.id.mainfragment);

if (fragment instanceof MainFragment){
  ((MainFragment)fragment).onSocketUp();
}

Post a Comment for "Call A Fragment's Method From Parent Activity"