Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Depois que uma cerca virtual for registrada, o app precisará adicionar um callback para responder
quando a cerca for acionada. Para isso, use uma subclasse de
BroadcastReceiver para processar métodos Intent de cercas.
Antes de adicionar callbacks a uma cerca, é necessário
registrar a cerca.
Criar uma subclasse de BroadcastReceiver
O exemplo a seguir mostra a classe FenceReceiver, que estende
BroadcastReceiver. A classe implementa o
método de callback BroadcastReceiver.onReceive() para processar todos os métodos Intent
originados de cercas criadas pelo app. Quando um Intent é recebido, o método
FenceState.extract()
é usado para receber o estado da cerca e transmiti-lo ao callback.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-06-24 UTC."],[[["After registering a fence, your app needs to add a callback to respond when the fence is triggered."],["Callbacks for fences are implemented using a subclass of `BroadcastReceiver` to manage `Intent` methods."],["The `BroadcastReceiver.onReceive()` method within the subclass handles `Intent` methods from the fences your app has created."],["The `FenceState.extract()` method is used to retrieve the fence state from a received `Intent` and provide it to the callback."]]],["After registering a fence, a callback must be added to respond when it's triggered. This is achieved by creating a subclass of `BroadcastReceiver`. The `FenceReceiver` class, extending `BroadcastReceiver`, implements the `onReceive()` method. Upon receiving an `Intent` from a fence, `FenceState.extract()` retrieves the fence state. The code then checks the fence key and current state (`TRUE`, `FALSE`, or `UNKNOWN`) to update the log view. This allows the app to react to fence state changes.\n"]]