这是我的代码
public class MainActivity extends Activity implements GoogleApiClient.ConnectionCallbacks,GoogleApiClient.OnConnectionFailedListener {
private GoogleApiClient mGoogleApiClient;
private String TAG = "app comm";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
int code = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getApplicationContext());
if (code == ConnectionResult.SUCCESS) {
Log.d(TAG, "success ");
buildGoogleApiClient();
} else {
Log.d(TAG, "fail ");
}
}
private void buildGoogleApiClient() {
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addApi(Nearby.CONNECTIONS_API).addConnectionCallbacks(this).addOnConnectionFailedListener(this).build();
}
@Override
public void onConnected(@Nullable Bundle bundle) {
Log.d(TAG,"connected");
}
@Override
public void onConnectionSuspended(int i) {
Log.d(TAG,"suspended");
}
@Override
public void onConnectionFailed(@NonNull ConnectionResult connectionResult) {
Log.d(TAG,"failed");
}
}
我是新手 我在raspberry pi 3中运行这个程序 我已经检查过,互联网正在运行。 isGoogleServicesAvailable返回true。 但没有一个覆盖方法被调用。我不知道我错过了什么。
这是我的日志
Connected to process 8191 on device google-iot_rpi3-192.168.1.2:5555
Capturing and displaying logcat messages from application. This behavior can be disabled in the "Logcat output" section of the "Debugger" settings page.
I/zygote: Late-enabling -Xcheck:jni
W/zygote: Using default instruction set features for ARM CPU variant (generic) using conservative defaults
I/InstantRun: starting instant run server: is main process
V/first log: first raspberry log message
D/app comm: success
D/vndksupport: Loading /vendor/lib/hw/android.hardware.graphics.mapper@2.0-impl.so from current namespace instead of sphal namespace.