簡體   English   中英

Google Awareness API無法在模擬器上注冊Fence

[英]Google Awareness API cannot register fence on emulator

我嘗試使用以下代碼更新籬笆:

AwarenessFence locationFence = LocationFence.entering(latitude, longitude, radius);

    Awareness.FenceApi.updateFences(
            mGoogleApiClient,
            new FenceUpdateRequest.Builder()
                    .addFence(LOCATION_FENCE_KEY, locationFence, mPendingIntent)
                    .build())
            .setResultCallback(new ResultCallback<Status>() {
                @Override
                public void onResult(@NonNull Status status) {
                    if (status.isSuccess()) {
                        Log.i(TAG, "Fence was successfully registered.");
                    } else {
                        Log.e(TAG, "Fence could not be registered: " + status);
                    }
                }
            });

它在物理設備上工作正常,但是在仿真器上,我收到以下logcat消息:

Status{statusCode=unknown status code: 7503, resolution=null}

有誰知道什么可能導致此問題?

您是否嘗試過在模擬器中設置位置? 此頁面上有說明:

https://developer.android.com/studio/run/emulator.html

根據文檔, 7503表示

ACL_ACCESS_DENIED:ACL身份驗證失敗。

但是,這似乎是模擬器問題,因為注冊TimeFence確實對我TimeFence 而位置圍欄和活動圍欄則沒有。

AwarenessFence timeFence = TimeFence.inSaturdayInterval(TimeZone.getDefault(), 0, 24 * 60 * 60 * 1000);

要使用Awareness API,您需要:

GooglePlayServices(在模擬器上為Google Apis)

到位置圍欄:在設備上激活了位置服務。 如果在模擬器或站立設備上,我認為您可以偽造它。

似乎活動檢測意識使用了一系列復雜的傳感器,例如加速度計,陀螺儀,位置等。因此,我現在不了解模擬器的效率如何。

最后,設備/仿真器需要Internet連接! 乍一看,您可以認為Awareness location API是一種離線服務。 不是 如果您檢查自己的Google Developer Console,則可以看到對Google服務器的感知請求。

錯誤由@jmols清楚地說明了:API正在嘗試訪問安全鏈以與感知服務建立連接,但失敗了。 可能是因為該設備沒有網絡連接。

如果您的仿真器具有互聯網連接,請在Google Developer控制台上仔細檢查此API的憑據。

暫無
暫無

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

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