Reputation: 1
I want to wake up my app with Eddystone, however nothing happened when my phone get close to the signal of Eddystone. I did it with Android Beacon library. And it is as blew:
`
onCreate(){
mBeaconManager = BeaconManager.getInstanceForApplication(this);
// Detect the main Eddystone-UID frame:
mBeaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
mBeaconManager.setBackgroundBetweenScanPeriod(50);
mBeaconManager.setBackgroundScanPeriod(50);
mBeaconManager.setForegroundBetweenScanPeriod(50);
mBeaconManager.setForegroundScanPeriod(50);
mBeaconManager.setBackgroundBetweenScanPeriod(50);
mBeaconManager.setForegroundScanPeriod(50);
mBeaconManager.applySettings();
mBeaconManager.bind(this);
}`
Android.xml:
<application
android:name="com.example.MyApplicationName"
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<!-- Note: the singleInstance below is important to keep two copies of your activity from getting launched on automatic startup -->
<activity
android:launchMode="singleInstance"
android:name="com.example.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
Is there anyone did it before, please help me with it. Thanks
Upvotes: 0
Views: 1292
Reputation: 64941
Yes, it is possible to wake up an app with Eddystone-UID using the Android Beacon Library. It works the same way as with AltBeacon or iBeacon.
The easiest way to get this to happen is to start with the reference app here:
https://github.com/altbeacon/android-beacon-library-reference
The only modification you need to make is to add the beacon parser for Eddystone-UID:
mBeaconManager.getBeaconParsers().add(new BeaconParser().
setBeaconLayout(BeaconParser.EDDYSTONE_UID_LAYOUT));
Looking at the code in the question, setting the scan periods to 50 is going to be a problem, as 50ms is not long enough to reliably detect a beacon. I would remove these custom scan period configurations and use the defaults.
A few tips:
Upvotes: 1