Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Nova Api de Localização Android
Search
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
José Caique Oliveira
November 10, 2017
Programming
0
95
Nova Api de Localização Android
Slides usados no TDC Porto Alegre
José Caique Oliveira
November 10, 2017
Tweet
Share
More Decks by José Caique Oliveira
See All by José Caique Oliveira
Kotlin Flow
jcaiqueoliveira
0
120
Coroutines And Flow
jcaiqueoliveira
2
120
Testing your app
jcaiqueoliveira
0
310
Modularizando seu app
jcaiqueoliveira
0
73
Arquitetura para android
jcaiqueoliveira
6
320
Kotlin por onde começar?
jcaiqueoliveira
1
98
Introdução ao Android
jcaiqueoliveira
1
89
Arquitetura para projetos Android
jcaiqueoliveira
1
240
Kotlin 1.1
jcaiqueoliveira
0
140
Other Decks in Programming
See All in Programming
CSC307 Lecture 08
javiergs
PRO
0
670
CSC307 Lecture 06
javiergs
PRO
0
690
Grafana:建立系統全知視角的捷徑
blueswen
0
330
高速開発のためのコード整理術
sutetotanuki
1
400
Package Management Learnings from Homebrew
mikemcquaid
0
220
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.6k
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
MDN Web Docs に日本語翻訳でコントリビュート
ohmori_yusuke
0
650
20260127_試行錯誤の結晶を1冊に。著者が解説 先輩データサイエンティストからの指南書 / author's_commentary_ds_instructions_guide
nash_efp
1
970
CSC307 Lecture 05
javiergs
PRO
0
500
登壇資料を作る時に意識していること #登壇資料_findy
konifar
4
1.1k
2026年 エンジニアリング自己学習法
yumechi
0
130
Featured
See All Featured
Conquering PDFs: document understanding beyond plain text
inesmontani
PRO
4
2.3k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
31
9.9k
The State of eCommerce SEO: How to Win in Today's Products SERPs - #SEOweek
aleyda
2
9.5k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
210
Documentation Writing (for coders)
carmenintech
77
5.3k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
710
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1k
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
320
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
StorybookのUI Testing Handbookを読んだ
zakiyama
31
6.6k
Building a Modern Day E-commerce SEO Strategy
aleyda
45
8.6k
Getting science done with accelerated Python computing platforms
jacobtomlinson
2
110
Transcript
Nova API de localização para Android Diminuindo fricção
Caique Oliveira Graduado em Ciência da computação - UFS Android
developer - Stone Apresentação
Trabalhando com localização no Android
Implementar GooglePlayServicesClient - ConnectionCallbacks - OnConnectionFailedListener
ConnectionCallbacks override fun onConnected(p0: Bundle?){ } override fun onConnectionSuspended(p0: Int){
}
OnConnectionFailedListener override fun onConnectionFailed(p0: ConnectionResult) { }
Configurar GoogleApiClient fun initGoogleApiClient() { if (mGoogleApiClient != null) {
mGoogleApiClient = GoogleApiClient.Builder( this) .addConnectionCallbacks( this) .addOnConnectionFailedListener( this) .addApi(LocationServices. API) .build() } mGoogleApiClient?.connect() }
Conectar ao Play Services override fun onStart() { mGoogleApiClient?.connect() super.onStart()
}
Desconectar de acordo com o ciclo de vida override fun
onStop() { mGoogleApiClient?.disconnect() super.onStop() }
fun getLocation(): Location { return LocationServices.FusedLocationApi .getLastLocation(mGoogleApiClient) }
Meu Deus do Céu
Todo app é a mesma coisa
“É realmente necessário que eu mesmo controle o GoogleApiClient?”
“Eu realmente preciso controlar o ciclo de vida dele?”
Android Architecture Components
Android Architecture Components - Menor escrita de código - Framework
gerencia o ciclo de vida - Traz uma melhor experiência para o desenvolvedor
Reduzindo o atrito ao trabalhar com Location
implementation ‘com.google.android.gms:play-services-location:11.6.0’
LastLocation LocationServices.getFusedLocationProviderClient(this) .lastLocation.addOnSuccessListener({ location -> Log.e("location", location.toString()) })
implementa OnFailureListener override fun onFailure(p0: Exception) { val statusCode =
(p0 as ApiException).statusCode when (statusCode) { RESOLUTION_REQUIRED -> { //Fix in Settings." } SETTINGS_CHANGE_UNAVAILABLE -> { //Fix in Settings." } } }
LastLocation LocationServices.getFusedLocationProviderClient(this) .lastLocation.addOnSuccessListener({ location -> Log.v("location", location.toString()) }).addOnFailureListener(this)
Location Updates LocationServices.getFusedLocationProviderClient(this) .requestLocationUpdates( locationRequest = mLocationRequest, locationCallback = mLocationCallback,
looper = Looper.myLooper())
Location Updates - Callback val mLocationCallback = object : LocationCallback()
{ override fun onLocationResult(result: LocationResult?) { super.onLocationResult(result) Log.v("location",locationResult?.lastLocation?.toString()) } }
Location Updates - Request val mLocationRequest = LocationRequest() .setInterval(UPDATE_INTERVAL_IN_MILLISECONDS) .setFastestInterval(UPDATE_INTERVAL_IN_MILLISECONDS)
.setPriority(LocationRequest.PRIORITY_HIGH_ACCURACY)
Temos agora o foco para obter de forma simples uma
localização ou resolver um problema
Obrigado! twitter: @_josecaique email:
[email protected]
slack android dev br: caique
github: jcaiqueoliveira https://goo.gl/E1QsJg
Referências https://goo.gl/dLZ8X2 https://goo.gl/itG6pa
enter.stone.com.br