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
Geofencing avec Google Places
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Robin Caroff
January 24, 2017
Programming
55
0
Share
Geofencing avec Google Places
Présentation du Geofencing sur Android avec Google Places.
Robin Caroff
January 24, 2017
More Decks by Robin Caroff
See All by Robin Caroff
Screenshot Testing pour Compose Preview
robincaroff
0
120
Migration Android 15
robincaroff
0
32
Migration Android 14
robincaroff
1
180
À la découverte du développement mobile (sans les maux de tête)
robincaroff
0
100
À la découverte du développement mobile (sans les maux de tête) - SHORT
robincaroff
0
220
Rex - Migration Android 13
robincaroff
0
73
App-Elles - Exemple de tech for good mobile à l'heure du confinement
robincaroff
0
120
From Dagger to Dagger Hilt
robincaroff
0
300
Android Async Talk
robincaroff
1
150
Other Decks in Programming
See All in Programming
柔軟なPDFレイアウトエディタを支える型システム設計 — Discriminated UnionとConditional Typeの実践
minako__ph
1
170
Firefoxにコントリビューションして得られた学び
ken7253
2
170
[BalkanRuby 2026] Drop your app/services!
palkan
3
550
密結合なバックエンドから TypeScript のコードを生成する
kemuridama
0
220
Agentic AI & UI: Arcitecture, HITL, Emerging Standards
manfredsteyer
PRO
0
110
AI時代のエンジニアリングの原則 / Engineering Principles in the AI Era
haru860
0
1.3k
Back to the roots of date
jinroq
0
880
When benchmarks go bad - what I learned from measuring performance wrong
hollycummins
0
390
Surviving Black Friday: 329 billion requests with Falcon!
ioquatix
0
3.2k
TypeSpec で繋ぐ複数プロダクトの型安全
maroon8021
1
110
エラー処理の温故知新 / history of error handling technic
ryotanakaya
7
1.9k
Hive Metastoreを通して学ぶIceberg REST Catalog ― 仕様から実装まで
okumin
0
160
Featured
See All Featured
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
180
Visualization
eitanlees
151
17k
Code Reviewing Like a Champion
maltzj
528
40k
Music & Morning Musume
bryan
47
7.2k
A better future with KSS
kneath
240
18k
How to Think Like a Performance Engineer
csswizardry
28
2.6k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
BBQ
matthewcrist
89
10k
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
世界の人気アプリ100個を分析して見えたペイウォール設計の心得
akihiro_kokubo
PRO
70
39k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
360
30k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
55
3.3k
Transcript
GEOFENCING AVEC GOOGLE PLACES ANDROID NANTES - JANVIER 2017 Par
@RobinCaroff
LE PROBLÈME
GEOFENCING https://developer.android.com
GEOFENCING https://developers.google.com
GEOFENCING Dépendances Gradle dependencies { compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1' compile 'com.google.android.gms:play-services:9.4.0' }a
dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.0.1' a
compile 'com.google.android.gms:play-services-location:9.4.0' }a GEOFENCING Dépendances Gradle
GEOFENCING dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:23.0.1'
a compile 'com.google.android.gms:play-services-location:9.4.0' compile 'com.google.android.gms:play-services-maps:9.4.0' compile 'com.google.android.gms:play-services-places:9.4.0' }a Dépendances Gradle
PERMISSIONS <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.robincaroff.mygeofencer" > <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application> ... </application> </manifest> Manifest
PERMISSIONS <application android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/maps_apikey"/> ... <service
android:name=".services.GeofenceTransitionsIntentService"/> </application> Manifest
PERMISSIONS <application android:label="@string/app_name" android:theme="@style/AppTheme" > <meta-data android:name="com.google.android.geo.API_KEY" android:value="@string/maps_apikey"/> ... <service
android:name=".services.GeofenceTransitionsIntentService"/> </application> Manifest pour Place Picker
PERMISSIONS La technique
PERMISSIONS La technique du
PERMISSIONS La technique du SPLASH SCREEN
PERMISSIONS @Override protected void onCreate(Bundle savedInstanceState) { ... checkPermissions(); }a
private void checkPermissions() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION); } else { goToMainActivity(); }b }c
PERMISSIONS @Override protected void onCreate(Bundle savedInstanceState) { ... checkPermissions(); }a
private void checkPermissions() { if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, PERMISSIONS_REQUEST_ACCESS_FINE_LOCATION); } else { goToMainActivity(); }b }c
GOOGLE API CLIENT protected synchronized void buildGoogleApiClient() { mGoogleApiClient =
new GoogleApiClient .Builder(context) .addConnectionCallbacks(this) .addOnConnectionFailedListener(this) .addApi(LocationServices.API) .addApi(Places.GEO_DATA_API) .addApi(Places.PLACE_DETECTION_API) .build(); }
GOOGLE API CLIENT @Override protected void onStart() { super.onStart(); mGoogleApiClient.connect();
} @Override protected void onStop() { super.onStop(); mGoogleApiClient.disconnect(); }
GEOFENCES https://developer.android.com
CREATE A GEOFENCE Geofence geofence = new Geofence.Builder() .setRequestId(STRING_ID) .setCircularRegion(
LATITUDE, LONGITUDE, RADIUS_IN_METERS ) .setExpirationDuration(EXPIRATION_IN_MILLISECONDS) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build());
CREATE A GEOFENCE Geofence geofence = new Geofence.Builder() .setRequestId(STRING_ID) .setCircularRegion(
LATITUDE, LONGITUDE, RADIUS_IN_METERS ) .setExpirationDuration(EXPIRATION_IN_MILLISECONDS) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build());
CREATE A GEOFENCE Geofence geofence = new Geofence.Builder() .setRequestId(STRING_ID) .setCircularRegion(
LATITUDE, LONGITUDE, RADIUS_IN_METERS ) .setExpirationDuration(EXPIRATION_IN_MILLISECONDS) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build());
CREATE A GEOFENCE Geofence geofence = new Geofence.Builder() .setRequestId(STRING_ID) .setCircularRegion(
LATITUDE, LONGITUDE, RADIUS_IN_METERS ) .setExpirationDuration(EXPIRATION_IN_MILLISECONDS) .setTransitionTypes(Geofence.GEOFENCE_TRANSITION_ENTER | Geofence.GEOFENCE_TRANSITION_EXIT) .build());
GEOFENCING REQUEST private GeofencingRequest getGeofencingRequest() { GeofencingRequest.Builder builder = new
GeofencingRequest.Builder(); builder.setInitialTrigger(GeofencingRequest.INITIAL_TRIGGER_ENTER); builder.addGeofences(mGeofenceList); return builder.build(); }
GEOFENCE INTENT private PendingIntent getGeofencePendingIntent() { if (mGeofencePendingIntent != null)
{ return mGeofencePendingIntent; } Intent intent = new Intent(this, GeofenceTransitionsIntentService.class); return PendingIntent.getService(this, 0, intent, PendingIntent. FLAG_UPDATE_CURRENT); }
START / STOP GEOFENCING LocationServices.GeofencingApi.addGeofences( mGoogleApiClient, getGeofencingRequest(), getGeofencePendingIntent() ).setResultCallback(this); LocationServices.GeofencingApi.removeGeofences(
mGoogleApiClient, getGeofencePendingIntent() ).setResultCallback(this);
START / STOP GEOFENCING LocationServices.GeofencingApi.addGeofences( mGoogleApiClient, getGeofencingRequest(), getGeofencePendingIntent() ).setResultCallback(this); LocationServices.GeofencingApi.removeGeofences(
mGoogleApiClient, getGeofencePendingIntent() ).setResultCallback(this);
None
NOT BORING AT ALL…
SHOW ME HOW IT WORKS !
TESTS ▸ Real testing ▸ Mock location apps ▸ Emulator
▸ Mock location provider
LIMITATIONS
LIMITATIONS 100 geofences par application et par utilisateur (pour un
device)
BEST PRACTICES ▸ Réduire l’utilisation de la batterie en changeant
la ‘réactivité’ des notifications ▸ Optimiser les rayons de geofences ▸ Surveiller seulement quand c’est nécessaire ▸ Utiliser les transitions DWELL plutôt que ENTER