In my android manifest, I have put like this.
<meta-data
android:name="com.google.android.nearby.messages.API_KEY"
android:value="somethingnsomethingsomething" />
<!-- Required for Nearby Connections -->
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
In my MainActivity, I wrote like this.
private void buildGoogleApiClient() {
if (mGoogleApiClient != null) {
return;
}
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Nearby.MESSAGES_API)
.addConnectionCallbacks(this)
.enableAutoManage(this, this)
.build();
}
@Override
public void onConnected(@Nullable Bundle bundle) {
Toast.makeText(getApplicationContext(), "onConnected", Toast.LENGTH_LONG).show();
mMessageListener = new MessageListener() {
@Override
public void onFound(Message message) {
Toast.makeText(getApplicationContext(), "Found message: " + new String(message.getContent()), Toast.LENGTH_LONG).show();
}
@Override
public void onLost(Message message) {
Toast.makeText(getApplicationContext(), "Found message: " + new String(message.getContent()), Toast.LENGTH_LONG).show();
}
};
SubscribeOptions options = new SubscribeOptions.Builder()
.setStrategy(Strategy.BLE_ONLY)
.build();
Nearby.getMessagesClient(this).subscribe(mMessageListener, options);
}
I am using estimote beacon and I think I successfully added in Google Beacon Dashboard. But I cannot discover my beacon. Is there something wrong?