# AndroidXRAnchorSubsystem

The Android XR implementation of the XRAnchorSubsystem so it can work seamlessly with ARAnchorManager.

## Summary

### Inheritance

Inherits from: `XRAnchorSubsystem`

| ### Public functions ||
|---|---|
| [GetPersistState](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#getpersiststate)`(TrackableId trackableId, out `[XRAnchorPersistStates](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xranchorpersiststates)` state)` | `bool` Get persistence state of the given anchor. |
| [GetPersistState](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#getpersiststate)`(Guid guid, out `[XRAnchorPersistStates](https://developer.android.com/develop/xr/unity/reference/namespace/Google/XR/Extensions#xranchorpersiststates)` state)` | `bool` Get persistence state of the given anchor by GUID. |
| [GetPersistentId](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#getpersistentid)`(TrackableId anchor)` | `Guid` Gets the persistent id associated with the given anchor. |
| [Persist](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#persist)`(TrackableId anchor)` | `bool` Try to save the *anchor* on device's local storage. |
| [TryGetAllPersistedIds](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#trygetallpersistedids)`(ref List< Guid > guids)` | `bool` Gets all persisted ids that currently are saved on device's local storage, it can be used in [TryLoad(Guid)](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#tryload) to retrieve the persisted anchors across multiple sessions or removed by [Unpersist(Guid)](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#unpersist). |
| [TryLoad](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#tryload)`(Guid guid)` | `bool` Try to load a persisted anchor from the given *guid* . |
| [Unpersist](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#unpersist)`(Guid guid)` | `bool` Try to remove a persisted anchor from device's local storage. |
| [Unpersist](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#unpersist)`(TrackableId trackableId)` | `bool` Try to remove a persisted anchor from device's local storage. |

## Public functions

### GetPersistState

```c#
bool GetPersistState(
  TrackableId trackableId,
  out XRAnchorPersistStates state
)
```  
Get persistence state of the given anchor.


| Details ||
|---|---|
| Parameters | |---|---| | `trackableId` | The anchor to get state from. | | `state` | The state of the anchor. | |
| **Returns** | Returns a boolean to indicate whether successfully got persistence state. |

### GetPersistState

```c#
bool GetPersistState(
  Guid guid,
  out XRAnchorPersistStates state
)
```  
Get persistence state of the given anchor by GUID.


| Details ||
|---|---|
| Parameters | |---|---| | `guid` | The GUID associated with the anchor to get state from. | | `state` | The state of the anchor. | |
| **Returns** | Returns a boolean to indicate whether successfully got persistence state. |

### GetPersistentId

```c#
Guid GetPersistentId(
  TrackableId anchor
)
```  
Gets the persistent id associated with the given anchor.

It can be used in [TryLoad(Guid)](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#tryload) to retrieve the persisted anchor across multiple sessions. If the *anchor* is not persisted, returns `Guid.Empty`.


| Details ||
|---|---|
| Parameters | |---|---| | `anchor` | The anchor to get the persistent id. | |
| **Returns** | The persistent id of the given anchor. |

### Persist

```c#
bool Persist(
  TrackableId anchor
)
```  
Try to save the *anchor* on device's local storage.


| Details ||
|---|---|
| Parameters | |---|---| | `anchor` | The anchor to save. | |
| **Returns** | Returns a boolen to indicate whether successfully saved the anchor on device's local storage. |

### TryGetAllPersistedIds

```c#
bool TryGetAllPersistedIds(
  ref List< Guid > guids
)
```  
Gets all persisted ids that currently are saved on device's local storage, it can be used in [TryLoad(Guid)](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#tryload) to retrieve the persisted anchors across multiple sessions or removed by [Unpersist(Guid)](https://developer.android.com/develop/xr/unity/reference/class/Google/XR/Extensions/AndroidXRAnchorSubsystem#unpersist).


| Details ||
|---|---|
| Parameters | |---|---| | `guids` | A list of all persisted ids. | |
| **Returns** | Returns a boolean to indicate whether successfully retrieved all stored ids. |

### TryLoad

```c#
bool TryLoad(
  Guid guid
)
```  
Try to load a persisted anchor from the given *guid* .


| Details ||
|---|---|
| Parameters | |---|---| | `guid` | The id associated with a persisted anchor. | |
| **Returns** | Returns a boolean to indicate whether successfully loaded the given *guid* . |

### Unpersist

```c#
bool Unpersist(
  Guid guid
)
```  
Try to remove a persisted anchor from device's local storage.


| Details ||
|---|---|
| Parameters | |---|---| | `guid` | The persistent id associated with the anchor to remove. | |
| **Returns** | Returns a boolean to indicate whether successfully removed the anchor from device's local storage. |

### Unpersist

```c#
bool Unpersist(
  TrackableId trackableId
)
```  
Try to remove a persisted anchor from device's local storage.


| Details ||
|---|---|
| Parameters | |---|---| | `trackableId` | The anchor to remove. | |
| **Returns** | Returns a boolean to indicate whether successfully removed the anchor from device's local storage. |