belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
NavUtils
public final class NavUtils
extends Object
| java.lang.Object | |
| ↳ | android.support.v4.app.NavUtils |
NavUtils provides helper functionality for applications implementing recommended Android UI navigation patterns. For information about recommended navigation patterns see Tasks and Back Stack from the developer guide and Navigation from the design guide.
Summary
Constants | |
|---|---|
String | PARENT_ACTIVITY
|
Public methods | |
|---|---|
static Intent | getParentActivityIntent(Context context, ComponentName componentName) Obtain an |
static Intent | getParentActivityIntent(Context context, Class<?> sourceActivityClass) Obtain an |
static Intent | getParentActivityIntent(Activity sourceActivity) Obtain an |
static String | getParentActivityName(Context context, ComponentName componentName) Return the fully qualified class name of a source activity's parent activity as specified by a |
static String | getParentActivityName(Activity sourceActivity) Return the fully qualified class name of sourceActivity's parent activity as specified by a |
static void | navigateUpFromSameTask(Activity sourceActivity) Convenience method that is equivalent to calling |
static void | navigateUpTo(Activity sourceActivity, Intent upIntent) Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process. |
static boolean | shouldUpRecreateTask(Activity sourceActivity, Intent targetIntent) Returns true if sourceActivity should recreate the task when navigating 'up' by using targetIntent. |
Inherited methods | |
|---|---|
java.lang.Object | |
Constants
PARENT_ACTIVITY
String PARENT_ACTIVITY
Constant Value: "android.support.PARENT_ACTIVITY"
Public methods
getParentActivityIntent
Intent getParentActivityIntent (Context context, ComponentName componentName)
Obtain an Intent that will launch an explicit target activity specified by sourceActivityClass's PARENT_ACTIVITY <meta-data> element in the application's manifest.
| Parameters | |
|---|---|
context | Context: Context for looking up the activity component for the source activity |
componentName | ComponentName: ComponentName for the source Activity |
| Returns | |
|---|---|
Intent | a new Intent targeting the defined parent activity of sourceActivity |
| Throws | |
|---|---|
PackageManager.NameNotFoundException | if the ComponentName for sourceActivityClass is invalid |
getParentActivityIntent
Intent getParentActivityIntent (Context context, Class<?> sourceActivityClass)
Obtain an Intent that will launch an explicit target activity specified by sourceActivityClass's PARENT_ACTIVITY <meta-data> element in the application's manifest.
| Parameters | |
|---|---|
context | Context: Context for looking up the activity component for sourceActivityClass |
sourceActivityClass | Class: Class object for an Activity class |
| Returns | |
|---|---|
Intent | a new Intent targeting the defined parent activity of sourceActivity |
| Throws | |
|---|---|
PackageManager.NameNotFoundException | if the ComponentName for sourceActivityClass is invalid |
getParentActivityIntent
Intent getParentActivityIntent (Activity sourceActivity)
Obtain an Intent that will launch an explicit target activity specified by sourceActivity's PARENT_ACTIVITY <meta-data> element in the application's manifest. If the device is running Jellybean or newer, the android:parentActivityName attribute will be preferred if it is present.
| Parameters | |
|---|---|
sourceActivity | Activity: Activity to fetch a parent intent for |
| Returns | |
|---|---|
Intent | a new Intent targeting the defined parent activity of sourceActivity |
getParentActivityName
String getParentActivityName (Context context, ComponentName componentName)
Return the fully qualified class name of a source activity's parent activity as specified by a PARENT_ACTIVITY <meta-data> element within the activity element in the application's manifest. The source activity is provided by componentName.
| Parameters | |
|---|---|
context | Context: Context for looking up the activity component for the source activity |
componentName | ComponentName: ComponentName for the source Activity |
| Returns | |
|---|---|
String | The fully qualified class name of sourceActivity's parent activity or null if it was not specified |
| Throws | |
|---|---|
PackageManager.NameNotFoundException | |
getParentActivityName
String getParentActivityName (Activity sourceActivity)
Return the fully qualified class name of sourceActivity's parent activity as specified by a PARENT_ACTIVITY <meta-data> element within the activity element in the application's manifest.
| Parameters | |
|---|---|
sourceActivity | Activity: Activity to fetch a parent class name for |
| Returns | |
|---|---|
String | The fully qualified class name of sourceActivity's parent activity or null if it was not specified |
navigateUpFromSameTask
void navigateUpFromSameTask (Activity sourceActivity)
Convenience method that is equivalent to calling . sourceActivity will be finished by this call. navigateUpTo(sourceActivity, getParentActivityIntent (sourceActivity))
Note: This method should only be used when sourceActivity and the corresponding parent are within the same task. If up navigation should cross tasks in some cases, see shouldUpRecreateTask(Activity, Intent).
| Parameters | |
|---|---|
sourceActivity | Activity: The current activity from which the user is attempting to navigate up |
navigateUpTo
void navigateUpTo (Activity sourceActivity, Intent upIntent)
Navigate from sourceActivity to the activity specified by upIntent, finishing sourceActivity in the process. upIntent will have the flag FLAG_ACTIVITY_CLEAR_TOP set by this method, along with any others required for proper up navigation as outlined in the Android Design Guide.
This method should be used when performing up navigation from within the same task as the destination. If up navigation should cross tasks in some cases, see shouldUpRecreateTask(Activity, Intent).
| Parameters | |
|---|---|
sourceActivity | Activity: The current activity from which the user is attempting to navigate up |
upIntent | Intent: An intent representing the target destination for up navigation |
shouldUpRecreateTask
boolean shouldUpRecreateTask (Activity sourceActivity, Intent targetIntent)
Returns true if sourceActivity should recreate the task when navigating 'up' by using targetIntent.
If this method returns false the app can trivially call navigateUpTo(Activity, Intent) using the same parameters to correctly perform up navigation. If this method returns true, the app should synthesize a new task stack by using TaskStackBuilder or another similar mechanism to perform up navigation.
| Parameters | |
|---|---|
sourceActivity | Activity: The current activity from which the user is attempting to navigate up |
targetIntent | Intent: An intent representing the target destination for up navigation |
| Returns | |
|---|---|
boolean | true if navigating up should recreate a new task stack, false if the same task should be used for the destination |
Annotations
Interfaces
- ActionBarDrawerToggle.Delegate
- ActionBarDrawerToggle.DelegateProvider
- ActivityCompat.OnRequestPermissionsResultCallback
- ActivityCompat.PermissionCompatDelegate
- FragmentManager.BackStackEntry
- FragmentManager.OnBackStackChangedListener
- LoaderManager.LoaderCallbacks
- NotificationCompat.Action.Extender
- NotificationCompat.Extender
- SharedElementCallback.OnSharedElementsReadyListener
- TaskStackBuilder.SupportParentable
Classes
- ActionBarDrawerToggle
- ActivityCompat
- ActivityManagerCompat
- ActivityOptionsCompat
- AlarmManagerCompat
- AppLaunchChecker
- AppOpsManagerCompat
- BundleCompat
- DialogFragment
- Fragment
- Fragment.SavedState
- FragmentActivity
- FragmentContainer
- FragmentController
- FragmentHostCallback
- FragmentManager
- FragmentManager.FragmentLifecycleCallbacks
- FragmentManagerNonConfig
- FragmentPagerAdapter
- FragmentStatePagerAdapter
- FragmentTabHost
- FragmentTransaction
- FrameMetricsAggregator
- JobIntentService
- ListFragment
- LoaderManager
- NavUtils
- NotificationCompat
- NotificationCompat.Action
- NotificationCompat.Action.Builder
- NotificationCompat.Action.WearableExtender
- NotificationCompat.BigPictureStyle
- NotificationCompat.BigTextStyle
- NotificationCompat.Builder
- NotificationCompat.CarExtender
- NotificationCompat.CarExtender.UnreadConversation
- NotificationCompat.CarExtender.UnreadConversation.Builder
- NotificationCompat.DecoratedCustomViewStyle
- NotificationCompat.InboxStyle
- NotificationCompat.MessagingStyle
- NotificationCompat.MessagingStyle.Message
- NotificationCompat.Style
- NotificationCompat.WearableExtender
- NotificationCompatExtras
- NotificationCompatSideChannelService
- NotificationManagerCompat
- RemoteInput
- RemoteInput.Builder
- ServiceCompat
- ShareCompat
- ShareCompat.IntentBuilder
- ShareCompat.IntentReader
- SharedElementCallback
- TaskStackBuilder
Exceptions