FragmentTransaction.java revision bc377841db05bd5197ffadb58ba52c54b2a85f16
12dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackbornpackage android.app;
22dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn
32dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn/**
42dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn * API for performing a set of Fragment operations.
52dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn */
6ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackbornpublic abstract class FragmentTransaction {
75ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
85ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Calls {@link #add(int, Fragment, String)} with a 0 containerViewId.
95ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
10ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction add(Fragment fragment, String tag);
115ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
125ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
135ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Calls {@link #add(int, Fragment, String)} with a null tag.
145ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
15ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction add(int containerViewId, Fragment fragment);
165ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
175ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
185ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Add a fragment to the activity state.  This fragment may optionally
195ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * also have its view (if {@link Fragment#onCreateView Fragment.onCreateView}
205ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * returns non-null) into a container view of the activity.
215ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
225ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param containerViewId Optional identifier of the container this fragment is
235ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * to be placed in.  If 0, it will not be placed in a container.
245ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param fragment The fragment to be added.  This fragment must not already
255ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * be added to the activity.
265ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param tag Optional tag name for the fragment, to later retrieve the
27247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn     * fragment with {@link FragmentManager#findFragmentByTag(String)
28247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn     * FragmentManager.findFragmentByTag(String)}.
295ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
305ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
315ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
32ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction add(int containerViewId, Fragment fragment, String tag);
335ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
345ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
355ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Calls {@link #replace(int, Fragment, String)} with a null tag.
365ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
37ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction replace(int containerViewId, Fragment fragment);
385ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
395ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
405ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Replace an existing fragment that was added to a container.  This is
415ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * essentially the same as calling {@link #remove(Fragment)} for all
425ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * currently added fragments that were added with the same containerViewId
435ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * and then {@link #add(int, Fragment, String)} with the same arguments
445ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * given here.
455ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
465ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param containerViewId Identifier of the container whose fragment(s) are
475ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * to be replaced.
485ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param fragment The new fragment to place in the container.
495ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param tag Optional tag name for the fragment, to later retrieve the
50247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn     * fragment with {@link FragmentManager#findFragmentByTag(String)
51247fe74c934cb3fba85aae7e051a8044f460fb11Dianne Hackborn     * FragmentManager.findFragmentByTag(String)}.
525ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
535ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
545ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
55ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction replace(int containerViewId, Fragment fragment, String tag);
565ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
575ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
585ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Remove an existing fragment.  If it was added to a container, its view
595ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * is also removed from that container.
605ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
615ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param fragment The fragment to be removed.
625ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
635ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
645ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
65ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction remove(Fragment fragment);
66f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn
67f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn    /**
685ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Hides an existing fragment.  This is only relevant for fragments whose
695ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * views have been added to a container, as this will cause the view to
705ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * be hidden.
715ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
725ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param fragment The fragment to be hidden.
735ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
745ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
755ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
76ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction hide(Fragment fragment);
775ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
785ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
79baa1553c8d125a55956d1a8b2966ccd100673179Jim Shuma     * Shows a previously hidden fragment.  This is only relevant for fragments whose
805ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * views have been added to a container, as this will cause the view to
815ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * be shown.
825ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
835ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @param fragment The fragment to be shown.
845ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     *
855ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * @return Returns the same FragmentTransaction instance.
865ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     */
87ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction show(Fragment fragment);
882b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell
892b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell    /**
902b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     * @return <code>true</code> if this transaction contains no operations,
91c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * <code>false</code> otherwise.
922b6230e0de4bac2829ac27b19e95ba75c3da82b4Adam Powell     */
93ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract boolean isEmpty();
945ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn
955ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn    /**
965ae74d6e89a30e79ea85c487b32223ef55314985Dianne Hackborn     * Bit mask that is set for all enter transitions.
97f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn     */
98ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public static final int TRANSIT_ENTER_MASK = 0x1000;
99f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn
100f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn    /**
101f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn     * Bit mask that is set for all exit transitions.
102f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn     */
103ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public static final int TRANSIT_EXIT_MASK = 0x2000;
104f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn
105f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn    /** Not set up for a transition. */
106ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public static final int TRANSIT_UNSET = -1;
107f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn    /** No animation for transition. */
108ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public static final int TRANSIT_NONE = 0;
1099ff82bf2b33513052500473d0d6d025a80dcecbfChet Haase    /** Fragment is being added onto the stack */
110ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public static final int TRANSIT_FRAGMENT_OPEN = 1 | TRANSIT_ENTER_MASK;
1119ff82bf2b33513052500473d0d6d025a80dcecbfChet Haase    /** Fragment is being removed from the stack */
112ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public static final int TRANSIT_FRAGMENT_CLOSE = 2 | TRANSIT_EXIT_MASK;
113327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn    /** Fragment should simply fade in or out; that is, no strong navigation associated
114327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn     * with it except that it is appearing or disappearing for some reason. */
115327fbd2c8fa294b919475feb4c74a74ee1981e02Dianne Hackborn    public static final int TRANSIT_FRAGMENT_FADE = 3 | TRANSIT_ENTER_MASK;
116811ed1065f39469cf2cf6adba22cab397ed88d5eChet Haase
117c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
118c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Set specific animation resources to run for the fragments that are
119bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     * entering and exiting in this transaction. These animations will not be
120bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     * played when popping the back stack.
121c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
122ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setCustomAnimations(int enter, int exit);
123bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase
124bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase    /**
125bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     * Set specific animation resources to run for the fragments that are
126bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     * entering and exiting in this transaction. The <code>popEnter</code>
127bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     * and <code>popExit</code> animations will be played for enter/exit
128bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     * operations specifically when popping the back stack.
129bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase     */
130bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase    public abstract FragmentTransaction setCustomAnimations(int enter, int exit,
131bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase            int popEnter, int popExit);
132bc377841db05bd5197ffadb58ba52c54b2a85f16Chet Haase
133c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
134c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Select a standard transition animation for this transaction.  May be
135c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * one of {@link #TRANSIT_NONE}, {@link #TRANSIT_FRAGMENT_OPEN},
136c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * or {@link #TRANSIT_FRAGMENT_CLOSE}
137c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
138ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setTransition(int transit);
139c6669ca63299219d815464129dac051ab2404286Dianne Hackborn
140c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
141c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Set a custom style resource that will be used for resolving transit
142c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * animations.
143c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
144ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setTransitionStyle(int styleRes);
145f121be737c59390d97e21a92be8e166001534c7dDianne Hackborn
146c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
147c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Add this transaction to the back stack.  This means that the transaction
148c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * will be remembered after it is committed, and will reverse its operation
149c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * when later popped off the stack.
150c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     *
151c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * @param name An optional name for this back stack state, or null.
152c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
153ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction addToBackStack(String name);
154dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn
155dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn    /**
1560c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * Returns true if this FragmentTransaction is allowed to be added to the back
1570c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * stack. If this method would return false, {@link #addToBackStack(String)}
1580c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * will throw {@link IllegalStateException}.
1590c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     *
1600c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * @return True if {@link #addToBackStack(String)} is permitted on this transaction.
1610c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     */
162ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract boolean isAddToBackStackAllowed();
1630c24a5514c1ff143a223720a090b19a86a75945fAdam Powell
1640c24a5514c1ff143a223720a090b19a86a75945fAdam Powell    /**
1650c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * Disallow calls to {@link #addToBackStack(String)}. Any future calls to
1660c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * addToBackStack will throw {@link IllegalStateException}. If addToBackStack
1670c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     * has already been called, this method will throw IllegalStateException.
1680c24a5514c1ff143a223720a090b19a86a75945fAdam Powell     */
169ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction disallowAddToBackStack();
1700c24a5514c1ff143a223720a090b19a86a75945fAdam Powell
1710c24a5514c1ff143a223720a090b19a86a75945fAdam Powell    /**
172c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Set the full title to show as a bread crumb when this transaction
173c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * is on the back stack, as used by {@link FragmentBreadCrumbs}.
174c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     *
175c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * @param res A string resource containing the title.
176c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
177ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbTitle(int res);
178c6669ca63299219d815464129dac051ab2404286Dianne Hackborn
179c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
180c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Like {@link #setBreadCrumbTitle(int)} but taking a raw string; this
181c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * method is <em>not</em> recommended, as the string can not be changed
182c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * later if the locale changes.
183c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
184ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbTitle(CharSequence text);
185c6669ca63299219d815464129dac051ab2404286Dianne Hackborn
186c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
187c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Set the short title to show as a bread crumb when this transaction
188c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * is on the back stack, as used by {@link FragmentBreadCrumbs}.
189c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     *
190c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * @param res A string resource containing the title.
191c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
192ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbShortTitle(int res);
193c6669ca63299219d815464129dac051ab2404286Dianne Hackborn
194c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
195c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * Like {@link #setBreadCrumbShortTitle(int)} but taking a raw string; this
196c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * method is <em>not</em> recommended, as the string can not be changed
197c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     * later if the locale changes.
198c6669ca63299219d815464129dac051ab2404286Dianne Hackborn     */
199ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract FragmentTransaction setBreadCrumbShortTitle(CharSequence text);
200c6669ca63299219d815464129dac051ab2404286Dianne Hackborn
201c6669ca63299219d815464129dac051ab2404286Dianne Hackborn    /**
202ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * Schedules a commit of this transaction.  The commit does
203dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     * not happen immediately; it will be scheduled as work on the main thread
204dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     * to be done the next time that thread is ready.
205dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     *
206ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * <p class="note">A transaction can only be committed with this method
207ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * prior to its containing activity saving its state.  If the commit is
208ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * attempted after that point, an exception will be thrown.  This is
209ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * because the state after the commit can be lost if the activity needs to
210ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * be restored from its state.  See {@link #commitAllowingStateLoss()} for
211ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * situations where it may be okay to lose the commit.</p>
212ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     *
213dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     * @return Returns the identifier of this transaction's back stack entry,
214dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     * if {@link #addToBackStack(String)} had been called.  Otherwise, returns
215dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     * a negative number.
216dd913a50cd72d6dd23c4ea437f0ebe2be05ca2e8Dianne Hackborn     */
217ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract int commit();
218ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn
219ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    /**
220ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * Like {@link #commit} but allows the commit to be executed after an
221ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * activity's state is saved.  This is dangerous because the commit can
222ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * be lost if the activity needs to later be restored from its state, so
223ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * this should only be used for cases where it is okay for the UI state
224ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     * to change unexpectedly on the user.
225ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn     */
226ab36acb39941ce981dddda9f9cf4d2d23a56fd26Dianne Hackborn    public abstract int commitAllowingStateLoss();
2272dedce6e84679ead961a485c7fe4b0f77c713b6aDianne Hackborn}
228