Java tutorial
//package com.java2s; /* * Copyright 2016 Google Inc. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import android.annotation.TargetApi; import android.bluetooth.le.AdvertiseData; import android.os.ParcelUuid; public class Main { private static final ParcelUuid EDDYSTONE_BEACON_UUID = ParcelUuid .fromString("0000FEAA-0000-1000-8000-00805F9B34FB"); private static final byte URL_FRAME_TYPE = 0x10; private static final byte FAT_BEACON = 0x0e; @TargetApi(21) public static AdvertiseData getFatBeaconAdvertisementData(byte[] fatBeaconAdvertisement) { // Manually build the advertising info int length = Math.min(fatBeaconAdvertisement.length, 17); byte[] beaconData = new byte[length + 3]; System.arraycopy(fatBeaconAdvertisement, 0, beaconData, 3, length); beaconData[0] = URL_FRAME_TYPE; beaconData[1] = (byte) 0xBA; beaconData[2] = FAT_BEACON; return new AdvertiseData.Builder().setIncludeTxPowerLevel(false) // reserve advertising space for URI .addServiceData(EDDYSTONE_BEACON_UUID, beaconData) // Adding 0xFEAA to the "Service Complete List UUID 16" (0x3) for iOS compatibility .addServiceUuid(EDDYSTONE_BEACON_UUID).build(); } }