Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Nova Api de Localização Android
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
José Caique Oliveira
November 10, 2017
Programming
110
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Nova Api de Localização Android
Slides usados no TDC Porto Alegre
José Caique Oliveira
November 10, 2017
More Decks by José Caique Oliveira
See All by José Caique Oliveira
Kotlin Flow
jcaiqueoliveira
0
140
Coroutines And Flow
jcaiqueoliveira
2
150
Testing your app
jcaiqueoliveira
0
340
Modularizando seu app
jcaiqueoliveira
0
90
Arquitetura para android
jcaiqueoliveira
6
330
Kotlin por onde começar?
jcaiqueoliveira
1
120
Introdução ao Android
jcaiqueoliveira
1
110
Arquitetura para projetos Android
jcaiqueoliveira
1
260
Kotlin 1.1
jcaiqueoliveira
0
160
Other Decks in Programming
See All in Programming
Go × SIMDで高速化するベクトル検索 ~ルーフラインモデルでSIMDが効く境界を探れ! ~
po3rin
1
170
LoopHub - ローカルで動く GitHub で、AI と共同開発
jugyo
1
470
DynamoDBの基礎を振り返りながらベクトル検索機能を理解する
musan
3
270
新卒PdEのリアル
ryu1013
1
470
go-spidermonkeyでAIエージェントのCode Modeを実装する
syumai
3
1.5k
XHTMLが残したもの
yosuke_furukawa
PRO
2
470
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
130
kubernetes コンポーネント開発入門 / 新卒N年目の勉強会&交流会!〜〇〇への誘い〜 #n_study
mazrean
0
180
thread_parallel_with_free-threaded_Python_and_NumPy.pdf
riku_sakamoto
0
210
フロントエンドUIフレームワークのこれまでとこれから
ssssota
2
1.4k
自分的「カンファレンスの楽しみ方」
syumai
0
200
AI時代に学ぶ 好きなルール 嫌いなルール Linter編
shorty5121
0
890
Featured
See All Featured
Discover your Explorer Soul
emna__ayadi
2
1.3k
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.8k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
B2B Lead Gen: Tactics, Traps & Triumph
marketingsoph
0
230
Product Roadmaps are Hard
iamctodd
55
13k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
Skip the Path - Find Your Career Trail
mkilby
1
220
Joys of Absence: A Defence of Solitary Play
codingconduct
1
500
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.8k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.8k
Chasing Engaging Ingredients in Design
codingconduct
0
300
Un-Boring Meetings
codingconduct
0
410
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