Android Activity Recognition not working with Nexus 5

后端 未结 3 1112
孤独总比滥情好
孤独总比滥情好 2021-01-23 11:57

I had a code working that was using Google\'s Activity Recognition Updates. Now all of a sudden these seem to send updates either several times per second or never although requ

3条回答
  •  隐瞒了意图╮
    2021-01-23 12:15

    As suggested by canopi, increase the detection 'time', in which 0 will give you the fastest result.

    I had encountered the same problem and instead of adding the build() part on onCreate directly, I added the method below and called it on onCreate(). Try to trace the code from this google sample. I got the code stripped down from there.

    protected synchronized void buildGoogleApiClient() {
        mGoogleApiClient = new GoogleApiClient.Builder(this)
                .addConnectionCallbacks(this)
                .addOnConnectionFailedListener(this)
                .addApi(ActivityRecognition.API)
                .build();
    }
    

    Also add buildGoogleApiClient() to your onCreate method.

提交回复
热议问题