SupportWalletFragment | Android Developers

Quicknav Quicknav
Links

- Google Play Developer Console
- Android Developers Blog
- About Android

Android Sites

- Android.com
- Android Developers
- Android Open Source Project

Language
close

- - About
  - Wear
  - TV
  - Auto
- - Get Started
  - Devices
  - Style
  - Patterns
  - Building Blocks
  - Downloads
  - Videos
- - Training
  - API Guides
  - Reference
  - Tools
  - Google Services
  - Samples
- - Google Play
  - Essentials
  - Get Users
  - Engage & Retain
  - Monetize
  - Tools & Reference
  - Developer Stories

## Results

Loading...
Summary: Nested Classes | Ctors | Methods | Inherited Methods | [Expand All]
public final class

# SupportWalletFragment

extends Fragment

java.lang.Object
↳ | android.support.v4.app.Fragment
| ↳ | com.google.android.gms.wallet.fragment.SupportWalletFragment

## Class Overview

This fragment is the simplest way to place a Wallet buy button or selection details UI in an application for the InstantBuy API. It automatically handles life cycle and user events, producing a `MaskedWallet` in the end. Being a fragment, the component can be added to an activity's layout with the XML below. Buy Button mode:

     <fragment
        android:name="com.google.android.gms.wallet.fragment.SupportWalletFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        wallet:environment="sandbox"
        wallet:mode="buyButton"/>

Selection Details mode:

     <fragment
        android:name="com.google.android.gms.wallet.fragment.SupportWalletFragment"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        wallet:environment="sandbox"
        wallet:mode="selectionDetails"/>

Alternatively it may also be created programmatically with `newInstance(WalletFragmentOptions)` and added to the activity's fragment manager.

The fragment must be initialized exactly once by calling `initialize(WalletFragmentInitParams)`. This sets a `MaskedWalletRequest` for buy button mode or `MaskedWallet` for selection details mode. For buy button mode the request may be modified with `updateMaskedWalletRequest(MaskedWalletRequest)`. When the button is clicked, the masked payment credentials of the user will be retrieved and returned in your activity's `onActivityResult` callback with a request code specified in `WalletFragmentInitParams`.

The fragment may be in one of four states at any time. It starts out in `UNINITIALIZED`. UI components are disabled in this state. Once `initialize(WalletFragmentInitParams)` is called, the fragment transitions into `READY`, where it is ready for user interaction. When the buy/change button is clicked, it transitions into `PROCESSING`. The button will be disabled to prevent further user interaction. Finally when the masked wallet result comes back, the fragment goes back into `READY`. Sometimes the fragment can also get into `WALLET_UNAVAILABLE` when the Wallet service is temporarily not available. UI components will be disabled in this state. You may receive state transition updates by setting a `SupportWalletFragment.OnStateChangedListener` via `setOnStateChangedListener(OnStateChangedListener)`.

To use this class, you must include the Android support library in your build path.

## Summary

Nested Classes
interface | SupportWalletFragment.OnStateChangedListener |

Public Constructors
| SupportWalletFragment()

Public Methods
int | getState() Returns the current state of the fragment.
void | initialize(WalletFragmentInitParams initParams) Initializes the fragment.
static SupportWalletFragment | newInstance(WalletFragmentOptions options) Creates a Wallet fragment with the given `options`.
void | onActivityResult(int requestCode, int resultCode, Intent data)
void | onCreate(Bundle savedInstanceState)
View | onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
void | onDestroy()
void | onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)
void | onPause()
void | onResume()
void | onSaveInstanceState(Bundle outState)
void | onStart()
void | onStop()
void | setEnabled(boolean enabled) Sets a boolean that will enable or disable the fragment's UI components when it's in `READY`.
void | setOnStateChangedListener(SupportWalletFragment.OnStateChangedListener listener) Sets a listener to receive state transition callbacks.
void | updateMaskedWallet(MaskedWallet maskedWallet) Modifies the `MaskedWallet`.
void | updateMaskedWalletRequest(MaskedWalletRequest request) Modifies the `MaskedWalletRequest`.

[Expand] Inherited Methods
From class android.support.v4.app.Fragment
void | dump(String arg0, FileDescriptor arg1, PrintWriter arg2, String[] arg3)
final boolean | equals(Object arg0)
final FragmentActivity | getActivity()
final Bundle | getArguments()
final FragmentManager | getChildFragmentManager()
final FragmentManager | getFragmentManager()
final int | getId()
LayoutInflater | getLayoutInflater(Bundle arg0)
LoaderManager | getLoaderManager()
final Fragment | getParentFragment()
final Resources | getResources()
final boolean | getRetainInstance()
final String | getString(int arg0)
final String | getString(int arg0, Object... arg1)
final String | getTag()
final Fragment | getTargetFragment()
final int | getTargetRequestCode()
final CharSequence | getText(int arg0)
boolean | getUserVisibleHint()
View | getView()
final boolean | hasOptionsMenu()
final int | hashCode()
static Fragment | instantiate(Context arg0, String arg1)
static Fragment | instantiate(Context arg0, String arg1, Bundle arg2)
final boolean | isAdded()
final boolean | isDetached()
final boolean | isHidden()
final boolean | isInLayout()
final boolean | isMenuVisible()
final boolean | isRemoving()
final boolean | isResumed()
final boolean | isVisible()
void | onActivityCreated(Bundle arg0)
void | onActivityResult(int arg0, int arg1, Intent arg2)
void | onAttach(Activity arg0)
void | onConfigurationChanged(Configuration arg0)
boolean | onContextItemSelected(MenuItem arg0)
void | onCreate(Bundle arg0)
Animation | onCreateAnimation(int arg0, boolean arg1, int arg2)
void | onCreateContextMenu(ContextMenu arg0, View arg1, ContextMenu.ContextMenuInfo arg2)
void | onCreateOptionsMenu(Menu arg0, MenuInflater arg1)
View | onCreateView(LayoutInflater arg0, ViewGroup arg1, Bundle arg2)
void | onDestroy()
void | onDestroyOptionsMenu()
void | onDestroyView()
void | onDetach()
void | onHiddenChanged(boolean arg0)
void | onInflate(Activity arg0, AttributeSet arg1, Bundle arg2)
void | onLowMemory()
boolean | onOptionsItemSelected(MenuItem arg0)
void | onOptionsMenuClosed(Menu arg0)
void | onPause()
void | onPrepareOptionsMenu(Menu arg0)
void | onResume()
void | onSaveInstanceState(Bundle arg0)
void | onStart()
void | onStop()
void | onViewCreated(View arg0, Bundle arg1)
void | onViewStateRestored(Bundle arg0)
void | registerForContextMenu(View arg0)
void | setArguments(Bundle arg0)
void | setHasOptionsMenu(boolean arg0)
void | setInitialSavedState(Fragment.SavedState arg0)
void | setMenuVisibility(boolean arg0)
void | setRetainInstance(boolean arg0)
void | setTargetFragment(Fragment arg0, int arg1)
void | setUserVisibleHint(boolean arg0)
void | startActivity(Intent arg0)
void | startActivityForResult(Intent arg0, int arg1)
String | toString()
void | unregisterForContextMenu(View arg0)
From class java.lang.Object
Object | clone()
boolean | equals(Object arg0)
void | finalize()
final Class<?> | getClass()
int | hashCode()
final void | notify()
final void | notifyAll()
String | toString()
final void | wait()
final void | wait(long arg0, int arg1)
final void | wait(long arg0)
From interface android.content.ComponentCallbacks
abstract void | onConfigurationChanged(Configuration arg0)
abstract void | onLowMemory()
From interface android.view.View.OnCreateContextMenuListener
abstract void | onCreateContextMenu(ContextMenu arg0, View arg1, ContextMenu.ContextMenuInfo arg2)

## Public Constructors

#### public SupportWalletFragment ()

## Public Methods

#### public int getState ()

Returns the current state of the fragment. See `WalletFragmentState` for list of possible values. Note that `UNKNOWN` may be returned under the following circumstances:

- before onStart() is executed
- when Google Play services is unavailable or requires update

#### public void initialize (WalletFragmentInitParams initParams)

Initializes the fragment. This must be called exactly once. Any further invocations after the first will be ignored.

#### public static SupportWalletFragment newInstance (WalletFragmentOptions options)

Creates a Wallet fragment with the given `options`.

#### public void onActivityResult (int requestCode, int resultCode, Intent data)

#### public void onCreate (Bundle savedInstanceState)

#### public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

#### public void onDestroy ()

#### public void onInflate (Activity activity, AttributeSet attrs, Bundle savedInstanceState)

#### public void onPause ()

#### public void onResume ()

#### public void onSaveInstanceState (Bundle outState)

#### public void onStart ()

#### public void onStop ()

#### public void setEnabled (boolean enabled)

Sets a boolean that will enable or disable the fragment's UI components when it's in `READY`. The UI components can not be disabled in other states and the boolean has no effect. This method is meant for temporarily disabling the buy button while you load data or update UI in your app.

#### public void setOnStateChangedListener (SupportWalletFragment.OnStateChangedListener listener)

Sets a listener to receive state transition callbacks.

#### public void updateMaskedWallet (MaskedWallet maskedWallet)

Modifies the `MaskedWallet`. This should be called after `initialize(WalletFragmentInitParams)`. Any non-null `maskedWallet` passed in here takes precedence over the `MaskedWallet` in `WalletFragmentInitParams` passed in `initialize(WalletFragmentInitParams)`.

#### public void updateMaskedWalletRequest (MaskedWalletRequest request)

Modifies the `MaskedWalletRequest`. This should be called after `initialize(WalletFragmentInitParams)`. Any non-null `request` passed in here takes precedence over the `MaskedWalletRequest` in `WalletFragmentInitParams` passed in `initialize(WalletFragmentInitParams)`.

Note that any user buy button click event before this method call would load a masked wallet using whatever `MaskedWalletRequest` available at that time.