目录

SupportMapFragment

Class Info

public class SupportMapFragment

Map component in an app, which can be used to add a map to the app in the simplest way. To obtain the map manager, call getMapAsync.

The HuaweiMap object must be obtained using getMapAsync(OnMapReadyCallback callback). This class will automatically initialize the map system and view.

Any object obtained from HuaweiMap will be associated with the view. Do not save objects (such as markers) out of the view's lifecycle. Otherwise, memory leaks will occur because the view cannot be released.

Public Constructor Summary

Constructor Name

SupportMapFragment()

Default constructor of the SupportMapFragment class.

Public Method Summary

Qualifier and Type

Method Name and Description

void

getMapAsync(OnMapReadyCallback callback)

Obtains a HuaweiMap object when the object is ready.

static SupportMapFragment

newInstance(HuaweiMapOptions options)

Creates a SupportMapFragment object with specified attributes.

static SupportMapFragment

newInstance()

Creates a SupportMapFragment object with default attributes.

void

onActivityCreated(Bundle savedInstanceState)

Lifecycle method inherited from Fragment.

void

onAttach(Activity activity)

Lifecycle method inherited from Fragment.

void

onCreate(Bundle savedInstanceState)

Lifecycle method inherited from Fragment.

View

onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)

Lifecycle method inherited from Fragment.

void

onDestroy()

Lifecycle method inherited from Fragment.

void

onDestroyView()

Lifecycle method inherited from Fragment.

void

onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState)

Lifecycle method inherited from Fragment. This method is called when SupportMapFragment is statically loaded in XML mode.

void

onLowMemory()

Lifecycle method inherited from Fragment.

void

onPause()

Lifecycle method inherited from Fragment.

void

onResume()

Lifecycle method inherited from Fragment.

void

onSaveInstanceState(Bundle outState)

Lifecycle method inherited from Fragment and called when Fragment is destroyed unexpectedly. It is used to save the status of a SupportMapFragment object before it is destroyed. Then, the status can be retrieved when onCreate(Bundle) is called again.

void

onStart()

Lifecycle method inherited from Fragment.

void

onStop()

Lifecycle method inherited from Fragment.

void

setArguments(Bundle args)

Lifecycle method inherited from Fragment and called when data needs to be passed to Fragment.

Public Methods

[h2]getMapAsync

Method

public void getMapAsync(OnMapReadyCallback callback)

Obtains a HuaweiMap object when the object is ready.

NOTE:
  • This method must be called in the main thread.
  • The callback will be executed in the main thread.
  • In rare cases, the callback is not triggered when the HuaweiMap object is destroyed immediately after being created.
  • The object provided by the callback of HuaweiMap is not null.

Parameters

Name

Description

callback

Callback to be executed when a map is ready for use.

[h2]newInstance(HuaweiMapOptions options)

Method

public static SupportMapFragment newInstance(HuaweiMapOptions options)

Creates a SupportMapFragment object with specified attributes.

Parameters

Name

Description

options

Attributes required for creating a SupportMapFragment object.

Returns

Type

Description

SupportMapFragment

SupportMapFragment object.

[h2]newInstance()

Method

public static SupportMapFragment newInstance()

Creates a SupportMapFragment object with default attributes.

Returns

Type

Description

SupportMapFragment

SupportMapFragment object.

[h2]onActivityCreated

Method

public void onActivityCreated(Bundle savedInstanceState)

Lifecycle method inherited from Fragment.

Parameters

Name

Description

savedInstanceState

Status to be saved for a SupportMapFragment object.

[h2]onAttach

Method

public void onAttach(Activity activity)

Lifecycle method inherited from Fragment.

Parameters

Name

Description

activity

Activity object bound to SupportMapFragment.

[h2]onCreate

Method

public void onCreate(Bundle savedInstanceState)

Lifecycle method inherited from Fragment.

Parameters

Name

Description

savedInstanceState

Status to be saved for a SupportMapFragment object.

[h2]onCreateView

Method

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

Lifecycle method inherited from Fragment.

Parameters

Name

Description

inflater

LayoutInflater object, which is used to search for controls in a layout.

container

Layout container.

savedInstanceState

Status to be saved for a SupportMapFragment object.

Returns

Type

Description

View

View object.

[h2]onDestroy

Method

public void onDestroy()

Lifecycle method inherited from Fragment.

[h2]onDestroyView

Method

public void onDestroyView()

Lifecycle method inherited from Fragment.

[h2]onInflate

Method

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

Lifecycle method inherited from Fragment. This method is called when SupportMapFragment is statically loaded in XML mode.

Parameters

Name

Description

activity

Activity object bound to SupportMapFragment.

attrs

Attributes used to create a SupportMapFragment object.

savedInstanceState

Status to be saved for a SupportMapFragment object.

[h2]onLowMemory

Method

public void onLowMemory()

Lifecycle method inherited from Fragment.

[h2]onPause

Method

public void onPause()

Lifecycle method inherited from Fragment.

[h2]onResume

Method

public void onResume()

Lifecycle method inherited from Fragment.

[h2]onSaveInstanceState

Method

public void onSaveInstanceState(Bundle outState)

Method inherited from Fragment and called when Fragment is destroyed unexpectedly. It is used to save the status of a SupportMapFragment object before it is destroyed. Then, the status can be retrieved when onCreate(Bundle) is called again.

Parameters

Name

Description

outState

Status to be saved for a SupportMapFragment object.

[h2]onStart

Method

public void onStart()

Lifecycle method inherited from Fragment.

[h2]onStop

Method

public void onStop()

Lifecycle method inherited from Fragment.

[h2]setArguments

Method

public void setArguments(Bundle args)

Lifecycle method inherited from Fragment and called when data needs to be passed to Fragment.

Parameters

Name

Description

args

Data to be passed to SupportMapFragment.