Code example for Fragment

Methods: getActivity

0
     * Used by an {@link Fragment} to install itself to the host activity. 
     * 
     * @see FragmentInstallable 
     */ 
    public static void installFragment(Fragment fragment) {
        final Activity a = fragment.getActivity();
        if (a instanceof FragmentInstallable) {
            ((FragmentInstallable) a).onInstallFragment(fragment);
        } 
    } 
 
    /** 
     * Used by an {@link Fragment} to uninstall itself from the host activity. 
     * 
     * @see FragmentInstallable 
     */ 
    public static void uninstallFragment(Fragment fragment) {
        final Activity a = fragment.getActivity();
        if (a instanceof FragmentInstallable) {
            ((FragmentInstallable) a).onUninstallFragment(fragment);