Stay organized with collections
Save and categorize content based on your preferences.
AdvertiseCallback
abstract class AdvertiseCallback
Bluetooth LE advertising callbacks, used to deliver advertising operation status.
Summary
Constants |
static Int |
Failed to start advertising as the advertising is already started.
|
static Int |
Failed to start advertising as the advertise data to be broadcasted is larger than 31 bytes.
|
static Int |
This feature is not supported on this platform.
|
static Int |
Operation failed due to an internal error.
|
static Int |
Failed to start advertising because no advertising instance is available.
|
Public methods |
open Unit |
Callback when advertising could not be started.
|
open Unit |
Callback triggered in response to android.
|
Constants
ADVERTISE_FAILED_ALREADY_STARTED
static val ADVERTISE_FAILED_ALREADY_STARTED: Int
Failed to start advertising as the advertising is already started.
Value: 3
ADVERTISE_FAILED_DATA_TOO_LARGE
static val ADVERTISE_FAILED_DATA_TOO_LARGE: Int
Failed to start advertising as the advertise data to be broadcasted is larger than 31 bytes.
Value: 1
ADVERTISE_FAILED_FEATURE_UNSUPPORTED
static val ADVERTISE_FAILED_FEATURE_UNSUPPORTED: Int
This feature is not supported on this platform.
Value: 5
ADVERTISE_FAILED_INTERNAL_ERROR
static val ADVERTISE_FAILED_INTERNAL_ERROR: Int
Operation failed due to an internal error.
Value: 4
ADVERTISE_FAILED_TOO_MANY_ADVERTISERS
static val ADVERTISE_FAILED_TOO_MANY_ADVERTISERS: Int
Failed to start advertising because no advertising instance is available.
Value: 2
Public constructors
AdvertiseCallback
AdvertiseCallback()
Public methods
onStartFailure
open fun onStartFailure(errorCode: Int): Unit
Callback when advertising could not be started.
Parameters |
errorCode |
Int: Error code (see ADVERTISE_FAILED_* constants) for advertising start failures. |
onStartSuccess
open fun onStartSuccess(settingsInEffect: AdvertiseSettings!): Unit
Callback triggered in response to android.bluetooth.le.BluetoothLeAdvertiser#startAdvertising indicating that the advertising has been started successfully.
Parameters |
settingsInEffect |
AdvertiseSettings!: The actual settings used for advertising, which may be different from what has been requested. |
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[null,null,["Last updated 2025-02-10 UTC."],[],[],null,["# AdvertiseCallback\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nAdvertiseCallback\n=================\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/bluetooth/le/AdvertiseCallback \"View this page in Java\") \n\n```\nabstract class AdvertiseCallback\n```\n\n|---|---------------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.bluetooth.le.AdvertiseCallback](#) |\n\nBluetooth LE advertising callbacks, used to deliver advertising operation status.\n\nSummary\n-------\n\n| Constants ||\n|-----------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ADVERTISE_FAILED_ALREADY_STARTED](#ADVERTISE_FAILED_ALREADY_STARTED:kotlin.Int) Failed to start advertising as the advertising is already started. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ADVERTISE_FAILED_DATA_TOO_LARGE](#ADVERTISE_FAILED_DATA_TOO_LARGE:kotlin.Int) Failed to start advertising as the advertise data to be broadcasted is larger than 31 bytes. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ADVERTISE_FAILED_FEATURE_UNSUPPORTED](#ADVERTISE_FAILED_FEATURE_UNSUPPORTED:kotlin.Int) This feature is not supported on this platform. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ADVERTISE_FAILED_INTERNAL_ERROR](#ADVERTISE_FAILED_INTERNAL_ERROR:kotlin.Int) Operation failed due to an internal error. |\n| static [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html) | [ADVERTISE_FAILED_TOO_MANY_ADVERTISERS](#ADVERTISE_FAILED_TOO_MANY_ADVERTISERS:kotlin.Int) Failed to start advertising because no advertising instance is available. |\n\n| Public constructors ||\n|------------------------------------------------------|---|\n| [AdvertiseCallback](#AdvertiseCallback())`()` \u003cbr /\u003e |\n\n| Public methods ||\n|-----------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStartFailure](#onStartFailure(kotlin.Int))`(`errorCode:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Callback when advertising could not be started. |\n| open [Unit](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html) | [onStartSuccess](#onStartSuccess(android.bluetooth.le.AdvertiseSettings))`(`settingsInEffect:` `[AdvertiseSettings](/reference/kotlin/android/bluetooth/le/AdvertiseSettings)!`)` Callback triggered in response to android. |\n\nConstants\n---------\n\n### ADVERTISE_FAILED_ALREADY_STARTED\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ADVERTISE_FAILED_ALREADY_STARTED: Int\n```\n\nFailed to start advertising as the advertising is already started. \n\n Value: 3\n\n### ADVERTISE_FAILED_DATA_TOO_LARGE\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ADVERTISE_FAILED_DATA_TOO_LARGE: Int\n```\n\nFailed to start advertising as the advertise data to be broadcasted is larger than 31 bytes. \n\n Value: 1\n\n### ADVERTISE_FAILED_FEATURE_UNSUPPORTED\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ADVERTISE_FAILED_FEATURE_UNSUPPORTED: Int\n```\n\nThis feature is not supported on this platform. \n\n Value: 5\n\n### ADVERTISE_FAILED_INTERNAL_ERROR\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ADVERTISE_FAILED_INTERNAL_ERROR: Int\n```\n\nOperation failed due to an internal error. \n\n Value: 4\n\n### ADVERTISE_FAILED_TOO_MANY_ADVERTISERS\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nstatic val ADVERTISE_FAILED_TOO_MANY_ADVERTISERS: Int\n```\n\nFailed to start advertising because no advertising instance is available. \n\n Value: 2\n\nPublic constructors\n-------------------\n\n### AdvertiseCallback\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nAdvertiseCallback()\n```\n\nPublic methods\n--------------\n\n### onStartFailure\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onStartFailure(errorCode: Int): Unit\n```\n\nCallback when advertising could not be started.\n\n| Parameters ||\n|-------------|------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `errorCode` | [Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html): Error code (see ADVERTISE_FAILED_\\* constants) for advertising start failures. |\n\n### onStartSuccess\n\nAdded in [API level 21](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun onStartSuccess(settingsInEffect: AdvertiseSettings!): Unit\n```\n\nCallback triggered in response to android.bluetooth.le.BluetoothLeAdvertiser#startAdvertising indicating that the advertising has been started successfully.\n\n| Parameters ||\n|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `settingsInEffect` | [AdvertiseSettings](/reference/kotlin/android/bluetooth/le/AdvertiseSettings)!: The actual settings used for advertising, which may be different from what has been requested. |"]]