簡體   English   中英

Android設備模擬器未使用GoogleApiClient連接到Google Play服務

[英]Android device emulator is not connecting to Google play services using GoogleApiClient

正如上面提到的,我使用了以下示例:在我的代碼中,《 Android定位新手指南》中,我放置了一個標記以在連接失敗時打印一條錯誤消息,如下所述:

@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
    Log.i(TAG, "Location services Failed to connect. Please reconnect.");

}

每當我的應用程序連接到Google Play服務時,都會調用此方法。 而我想調用onConnected方法

 @Override
public void onConnected(Bundle bundle) {
    Log.i(TAG, "Location services connected.");
    currentLocation = LocationServices.FusedLocationApi.getLastLocation(
            mGoogleApiClient);
    Location location = LocationServices.FusedLocationApi.getLastLocation(mGoogleApiClient);
    if(location== null)
    {

    }
    else
    {
        handleNewLocation(location);
        if (currentLocation != null) {
            display.setText("Latitude: "+ String.valueOf(currentLocation.getLatitude())+"Longitude: "+
                    String.valueOf(currentLocation.getLongitude()));
        }
    }

}

另外我還想補充一點,我的Genymotion VM中已經安裝了Google Play服務,但我無法進入Play商店,所以任何人都可以幫助我請問問題出在哪里?

在“”中標記單詞,然后嘗試

Log.i(“ TAG”,“位置服務無法連接。請重新連接。”);

如果您使用的是android studio,請在日志級別中選擇錯誤並在其中搜索您的TAG。

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM