简体   繁体   中英

Awareness API - Place type home

On google awareness API Guides page there is mention about Context types.

Contextual data includes sensor-derived data such as location (lat/lng), place (home, work, coffee shop)

However, on reference page with Places type Place reference , there is no mention about Home type. Is there a way to find out if user is at home (of course if he has it set up in his google settings)?

A bit late to the party, but now that Google's Awareness API has deprecated Places, you can use the NumberEight SDK as an alternative. One bonus is that it works on iOS too.

It performs a wide variety of context recognition tasks including:

  • Real-time physical activity detection
  • Current place categories (including Work and Home, which can trigger even without GPS)
  • Motion detection
  • Reachability
  • Local weather

It can also record user context for reports and analysis via the online portal.

To quickly check when a user is at home in Kotlin, you would write:

val ne = NumberEight()

ne.onPlaceUpdated { glimpse ->
    val place = glimpse.mostProbable

    if (place.context.home == Knowledge.AtPlaceContext) {
        Log.d("MyApp", "User is at home!")
    }
}

Here are some iOS and Android example projects.

Disclosure: I'm one of the developers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM