[英]How to check whether app is succesfully connected to Google Nearby Api key?
即使密钥错误或未提供,我们的应用也可以连接到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();
}
如果您尝试发布或订阅,将发生失败。 连接GoogleApiClient不会导致调用我们的服务器,因此不使用密钥。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.