Как проверить, успешно ли подключено приложение к ключу Google Nearby Api?
Наши приложения могут подключаться к GoogleAPIClient
даже если ключ неверен или не поставляется.
<meta-data
android:name="com.google.android.nearby.messages.API_KEY"
android:value="ourapikey" />
MainActivity.java
public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Nearby.MESSAGES_API)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.enableAutoManage(this, this) //enable auto manage
.build();
@Override
public void onConnected(@Nullable Bundle bundle) {
//THIS method is called -> we assume the GoogleApiClient therefore is successfully connected
backgroundSubscribe();
}
1 ответ
Ошибка произойдет, если вы попытаетесь опубликовать или подписаться. Подключение GoogleApiClient не приводит к звонку на наши серверы, поэтому ключ не используется.