2017-12-11 2 views
0

여기 내 코드내가 라즈베리 파이 3 내가 확인하고 인터넷이 작동에서이 프로그램을 실행이 새로운 오전

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"); 
    } 

} 

안드로이드 상황에서 구글의 API 클라이언트에 연결할 수 없습니다. isGoogleServicesAvailable이 true를 반환합니다. 하지만 호출 된 대체 메소드가 없습니다. 내가 뭘 놓치고 있는지 모르겠다.

여기, 당신이 실제로 연결을 시작하고 콜백을 제공 무엇 인을 구축 한 후 connect 메소드를 호출하지 않는 당신의 코드를 보면 내 로그

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/[email protected] from current namespace instead of sphal namespace. 

답변

1

입니다.

관련 문제