473,408 Members | 2,477 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

How to Detect Beacon in Android?

Hi,

I would like to know that "how can we detect Beacon in Android", which is a device that is designed to attract attention to specific locations.
Aug 22 '16 #1
3 2284
Brilstern
208 100+
The Android OS does not have any code that detects iBeacons, but it does have code that allows you to scan for Bluetooth LE devices, which are a lower-level device than an iBeacon.

You can roll-your own code that detects iBeacons using this Bluetooth LE scanning. That's exactly what the Android iBeacon Library from Radius Networks does. It is open source, so if you don't want to use the library, you can simply copy blocks of code out of the library and do your own detection.

The source code is here: http://github.com/AltBeacon/android-beacon-library

If you detection use cases are very simple, this might work fine. Be careful not to bite off too much work, though, because handling all the edge cases can become increasingly complex. That's certainly what I learned when writing the library.

If you just want to play with this, I would focus on one class from the library: IBeacon.java

This class can convert from an Android Blueooth LE scan record to an IBeacon (if the scanned Bluetooth device is indeed an iBeacon)

You can read about how to set up Bluetooth LE scanning on Android here: http://developer.android.com/guide/t...etooth-le.html
Aug 24 '16 #2
Hi Ashish,
The open source Android iBeacon Library will allow you to do this.

Here is a basic code sample:

public class MonitoringActivity extends Activity implements IBeaconConsumer {
protected static final String TAG = "RangingActivity";
private IBeaconManager iBeaconManager = IBeaconManager.getInstanceForApplication(this);

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
iBeaconManager.bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
iBeaconManager.unBind(this);
}
@Override
public void onIBeaconServiceConnect() {
iBeaconManager.setMonitorNotifier(new MonitorNotifier() {
@Override
public void didEnterRegion(Region region) {
Log.i(TAG, "I just saw an iBeacon for the firt time!");
}

@Override
public void didExitRegion(Region region) {
Log.i(TAG, "I no longer see an iBeacon");
}

@Override
public void didDetermineStateForRegion(int state, Region region) {
Log.i(TAG, "I have just switched from seeing/not seeing iBeacons: "+state);
}
});

try {
iBeaconManager.startMonitoringBeaconsInRegion(new Region("myMonitoringUniqueId", null, null, null));
} catch (RemoteException e) { }
}

}

I hope this will help you.
Dec 2 '16 #3
Beacons are the tiny devices that allow transmission of data in the form of Bluetooth frames. Beacons have limited information to transfer hence we call it lightweight devices.Check this link it can solve your issue.

https://www.mindstick.com/Forum/12639/how-to-get-correct-beaconlayout

https://devzone.nordicsemi.com/question/77611/how-to-detect-ble-beacons-on-android-tablet/
Dec 3 '16 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
Nepomuk
by: Nepomuk | last post by:
Android development is a pretty broad field and no one article could ever hope to encompass everything there is to learn. For that reason, this article attempts to collect links to various tutorials,...
1
by: Niels Koomans | last post by:
$ make j4 ============================================ PLATFORM_VERSION_CODENAME=REL PLATFORM_VERSION=4.4 TARGET_PRODUCT=aosp_x86 TARGET_BUILD_VARIANT=eng TARGET_BUILD_TYPE=release...
0
by: Niels Koomans | last post by:
Hello dear developers, Today i tried to make a build for Android-x86 version Kitkat 4.4.2. I got a error during the end of build while creating system.img: + '' /bin/bash: / 2048 *...
0
by: WhatsTheQuestio | last post by:
At this point I know how to utilize Google Maps within Android but it always seems to take up the full window, there is an image below which shows what I'm attempting to accomplish (having a box...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.