SlideShare une entreprise Scribd logo
1  sur  64
Télécharger pour lire hors ligne
LOCATION BASED
SOLUTIONS
IN THE
ANDROID
REALMThere are many ways to Rome, some may look quite surprising
Jürgen Fey . CTO matchinguu
AGENDA
•  Matchinguu	
  backgrounder	
  
•  Loca2on	
  Provider	
  Technologies	
  for	
  Android	
  devices	
  
•  Use	
  cases	
  
	
  
SOME INFO
ABOUT US
WE ARE THE EXPERT FOR ”LOCATION
BASED SOLUTIONS” WITH THE CLEAR
FOCUS ON MOBILE.
matchinguu	
  is	
  a	
  startup	
  based	
  in	
  Munich,	
  
Germany	
  (headcount:	
  9+).	
  We	
  started	
  in	
  2013	
  
with	
  a	
  clear	
  target:	
  
matchinguu	
  is	
  providing	
  a	
  comprehensive	
  API	
  for	
  
Android	
  and	
  iOS	
  as	
  well	
  as	
  the	
  needed	
  backend	
  
services	
  and	
  hardware	
  infrastructure	
  to	
  allow	
  
businesses	
  to	
  integrate	
  even	
  complex	
  LBS	
  
scenarios	
  fast.	
  	
  
Yes,	
  we	
  also	
  built	
  complete,	
  custom	
  apps.	
  	
  	
  	
  
	
  	
  	
  	
  	
  	
  	
  	
  
OUR
SERVICES
ANDROID API
Easy	
  to	
  integrate	
  API	
  for	
  
various	
  loca2on	
  
providers.	
  Event	
  system.	
  
Power	
  management.	
  
	
  
	
  
iOS API
Easy	
  to	
  integrate	
  API	
  for	
  
various	
  loca2on	
  
providers.	
  Event	
  system.	
  
Power	
  management.	
  
	
  
	
  BACKEND SaaS
Customer	
  dashboard	
  to	
  
control	
  loca2ons	
  and	
  
events.	
  Heatmaps,	
  Process	
  
automa2on,	
  repor2ng	
  and	
  
more…	
  
	
  
	
  
HARDWARE
Local	
  hotspot,	
  business	
  
intelligence,	
  Beacons,	
  
Backend	
  adapters	
  and	
  
more	
  .	
  
	
  
LOCATION PROVIDERS ON
MOBILE PLATFORMS
CELL-ID
WLAN
GPS
FUSED LOCATION PROVIDER
GEOHASH
SENSORS
GEOFENCES
BEACONS
IOT
NFC
Many	
  op(ons	
  
The	
  mobile	
  plaSorm	
  (Android)	
  
provides	
  a	
  wide	
  range	
  of	
  LBS	
  
op2ons.	
  	
  
	
  
Combine	
  and/or	
  use	
  wisely	
  
While	
  one	
  might	
  be	
  tempted	
  to	
  
use	
  the	
  best	
  providers	
  at	
  any	
  given	
  
2me	
  just	
  to	
  be	
  save	
  the	
  user	
  will	
  
not	
  tolerate	
  the	
  resul2ng	
  power	
  
drain.	
  
CELL-ID
If	
  the	
  mobile	
  device	
  is	
  connected	
  to	
  a	
  network	
  cell	
  (through	
  the	
  modem	
  part)	
  
the	
  „Cell-­‐ID“	
  provides	
  a	
  clear	
  loca2on	
  fingerprint	
  
•  The	
  network	
  base	
  sta2ons	
  (Base	
  Transceiver	
  Sta2on,	
  Cell)	
  are	
  sta2c	
  
loca2on	
  reference	
  points	
  
•  The	
  loca2ons	
  are	
  known	
  to	
  the	
  providers,	
  Google	
  and	
  other	
  service	
  
providers	
  
•  Triangula2on	
  allows	
  one	
  to	
  guess	
  a	
  loca2on	
  with	
  smaller	
  error	
  burden	
  
Accuracy:	
  From	
  <	
  100m	
  to	
  >	
  20	
  km	
  	
  
Public	
  Cell-­‐ID	
  databases	
  	
  
	
  OpenCellID	
  (h_p://wiki.opencellid.org/wiki/API)	
  
	
  unwiredlabs	
  Loca2onAPI	
  	
  (h_p://unwiredlabs.com/)	
  
	
  
CELL-ID
Use	
  TelephonyManager	
  to	
  retrieve	
  current	
  	
  
•  CellID	
  
•  MNC	
  (Mobile	
  Network	
  Code)	
  
•  MCC	
  (Mobile	
  Country	
  Code)	
  
•  LAC	
  (Loca2on	
  Area	
  Code)	
  
	
  
Use	
  PhoneStateListener	
  and	
  onCellInfoChanged	
  callback	
  to	
  retrieve	
  new	
  Cell-­‐ID	
  
info	
  (device	
  must	
  be	
  awake!	
  wakelock)	
  
	
  
Power	
  Factor:	
  very	
  low,	
  for	
  constant	
  background	
  updates	
  higher	
  	
  
Android	
  Reference:	
  	
  
h_p://developer.android.com/reference/android/telephony/CellLoca2on.html	
  
	
  
CELL-ID
Example	
  
	
  
TelephonyManager tManager =
(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation cellLocation =
(GsmCellLocation)tManager.getCellLocation();
String networkOperator = tManager.getNetworkOperator();
String mcc = networkOperator.substring(0, 3);
String mnc = networkOperator.substring(3);
int cid = cellLocation.getCid();
int lac = cellLocation.getLac();
CELL-ID
Nice	
  Android	
  appS:	
  	
  
•  OpenSignal	
  
•  Cell	
  WIDGET	
  
CELL-ID
Sidenote:	
  
By	
  using	
  an	
  IMSI	
  catcher	
  (you	
  might	
  Google	
  for	
  that	
  one...)	
  an	
  en2ty	
  other	
  
than	
  the	
  official	
  provider	
  may	
  „provide“	
  you	
  with	
  an	
  alterna2ve	
  Cell,	
  which	
  
takes	
  over	
  the	
  task	
  of	
  network	
  connec2vity.	
  	
  
	
  
IMSI	
  catcher	
  detec2on:	
  	
  
h_p://forum.xda-­‐developers.com/showthread.php?t=1422969	
  
	
  
WLAN
The	
  WLAN	
  signal	
  is	
  a	
  perfect	
  reference	
  for	
  quite	
  accurate	
  loca2on	
  info.	
  
How	
  does	
  Google	
  get	
  this	
  valuable	
  info?	
  
	
  It´s	
  YOU!	
  	
  
Add	
  the	
  following	
  ingredients	
  to	
  the	
  sweet	
  cake:	
  
•  Android	
  Device	
  
•  GPS	
  and	
  other	
  Loca2on	
  Providers	
  
•  Network	
  connec2on	
  
No	
  need	
  to	
  use	
  Maps	
  etc	
  –	
  they	
  do	
  it	
  anyways	
  (occasionally,	
  anonymously)	
  
BTW:	
  Apple,	
  Microsok	
  et	
  al	
  are	
  working	
  the	
  same	
  way	
  
Public	
  Database:	
  h_p://www.openwlanmap.org/	
  
WLAN
Each	
  WLAN	
  Access	
  Point	
  can	
  be	
  defined	
  by	
  	
  
•  SSID	
  (Service	
  Set	
  Iden2fier)	
  
•  MAC	
  Address	
  (unique	
  network	
  hardware	
  address)	
  
By	
  merging	
  the	
  info	
  about	
  an	
  SSID	
  and	
  all	
  other	
  Loca2on	
  Providers	
  (when	
  available)	
  it	
  is	
  
possible	
  to	
  build	
  up	
  a	
  Loca2on	
  Database	
  using	
  just	
  SSIDs.	
  
	
  
This	
  is	
  what	
  is	
  happening	
  –	
  each	
  SSID	
  can/may	
  be	
  used	
  for	
  Loca2on	
  info	
  	
  
	
  
Known	
  SSIDs	
  can	
  be	
  used	
  for	
  inhouse	
  apps	
  (Custom	
  WLAN	
  Proximity)	
  	
  	
  
	
  
Power	
  Factor:	
  high	
  when	
  always	
  on,	
  „manageable“	
  for	
  proximity	
  use	
  case	
  
Android	
  Tutorial:	
  h_p://www.tutorialspoint.com/android/android_wi_fi.htm	
  	
  
	
  
GEOHASH
GeoHashing	
  is	
  using	
  a	
  specially	
  prepared	
  text	
  info	
  for	
  high	
  accurary	
  loca2on.	
  
A	
  single	
  GeoHash	
  string	
  provides	
  info	
  for	
  a	
  two	
  coordinate	
  loca2on	
  
Depending	
  on	
  the	
  string	
  length	
  the	
  accuracy	
  increases	
  
8	
  characters:	
  	
  38/19m	
  
12	
  characters:	
  4/2	
  cm	
  
	
  
	
  
	
  
	
  	
  
h_p://unterbahn.com/2009/11/metric-­‐dimensions-­‐of-­‐geohash-­‐par22ons-­‐at-­‐the-­‐equator/	
  
GEOHASH
GEOHASH
GEOHASH
Example:	
  h_p://geohash.org/u33d8m58g	
  	
  	
  (Gleisdreieck	
  Berlin)	
  
Some	
  databases	
  support	
  GeoHashing	
  (MongoDB,	
  SOLR	
  etc.)	
  
	
  
Matchinguu	
  uses	
  the	
  GeoHash	
  info	
  as	
  part	
  of	
  the	
  SSID	
  for	
  customer	
  APs	
  	
  
	
  
SSID:	
  „magic_u33d8m58g_zH232J_powered	
  by	
  matchinguu“	
  
	
  
Anyone	
  interested	
  to	
  provide	
  an	
  open	
  source	
  repo	
  for	
  such	
  kind	
  of	
  locSSID?	
  (lets	
  
talk)	
  
	
  
Nice	
  demo:	
  h_p://geohash.gofreerange.com/	
  
	
  
	
  
GPS
The	
  „bread-­‐and-­‐bu_er“	
  Loca2on	
  provider.	
  	
  
Dedicated	
  GPS	
  hardware	
  
Accuracy	
  for	
  public	
  uses	
  cases:	
  down	
  to	
  3m	
  
Update	
  rate:	
  down	
  to	
  1s	
  
TTFF	
  (Time	
  To	
  First	
  Fix):	
  may	
  take	
  loooong	
  
	
  needs	
  to	
  „see“	
  at	
  least	
  3	
  satellites	
  –	
  the	
  more	
  the	
  be_er	
  
	
  usually	
  in	
  less	
  than	
  a	
  minute,	
  but	
  s2ll	
  ...	
  
Power	
  Factor:	
  very	
  high	
  	
  (80..150	
  mA)	
  
	
  
Android	
  Example:	
  
h_p://www.codeproject.com/Ar2cles/665527/A-­‐GPS-­‐Loca2on-­‐Ploqng-­‐Android-­‐
Applica2on	
  
	
  
	
  	
  
GPS
For	
  GPS	
  and	
  any	
  other	
  loca2on	
  providers:	
  
Use	
  BroadcastReceiver	
  or	
  Service	
  with	
  LocaEonListener	
  to	
  set	
  up	
  true	
  
background	
  processing.	
  
BroadcastReceiver:	
  Android	
  adds	
  your	
  receiver	
  during	
  boot	
  2me	
  (if	
  listed	
  in	
  
Manifest).	
  Quite	
  nice	
  for	
  apps	
  working	
  in	
  background.	
  	
  
Alterna2ve:	
  Register	
  during	
  run2me	
  and	
  send	
  an	
  PendingIndent	
  .	
  This	
  is	
  
be_er	
  when	
  you	
  need	
  to	
  cope	
  with	
  states.	
  
	
  
Service:	
  Generally	
  a	
  bit	
  heavier	
  but	
  s2ll	
  also	
  ok.	
  
GPS
Unofficial	
  features:	
  
<uses-permission android:name=„android.permission.ACCESS_LOCATION_EXTRACOMMANDS“ />
	
  
	
  
http://androidxref.com/	
  
GPS
When	
  used	
  wisely,	
  GPS	
  is	
  a	
  top	
  notch	
  provider	
  for	
  accurate	
  loca2on	
  
informa2on	
  –	
  use	
  it	
  wisely	
  and	
  only	
  when	
  needed	
  and	
  you	
  are	
  save.	
  
Do	
  not	
  use	
  it	
  as	
  the	
  sole	
  source,	
  if	
  possible.	
  
Always	
  keep	
  the	
  power	
  consump2on	
  in	
  mind.	
  
GPS	
  must	
  be	
  turned	
  on	
  –	
  in	
  case	
  you	
  need	
  to	
  ask	
  the	
  user	
  to	
  ac2vate.	
  
SENSORS
Sensors	
  are	
  playing	
  an	
  increasingly	
  important	
  role	
  when	
  dealing	
  with	
  loca2on-­‐aware	
  solu2ons.	
  	
  
They	
  may	
  be	
  used	
  to	
  help	
  „guessing“	
  movements,	
  hence	
  a	
  new	
  loca2on	
  –	
  or	
  just	
  to	
  reduce	
  power	
  
consump2on.	
  
	
  
There	
  are	
  three	
  general	
  sensor	
  groups	
  supported	
  by	
  Android:	
  
•  Mo2on	
  sensors	
  
•  Accelerometer	
  
•  Gravity	
  
•  Gyroscope/Rota2onal	
  Vector	
  
•  Environmental	
  sensors	
  
•  Temperatur	
  
•  Light/Sound	
  
•  Air	
  Pressure/Humidity	
  
•  Posi2on	
  sensors	
  
•  Orienta2on	
  
•  Magnetometer	
  
SENSORS
The	
  number	
  of	
  available	
  sensors,	
  their	
  capabili2es	
  and	
  accuracy	
  does	
  vary!	
  
There	
  is	
  no	
  thing	
  as	
  a	
  generic	
  sensor	
  in	
  each	
  category.	
  
There	
  might	
  be	
  mul2ple	
  sensors	
  per	
  category	
  –	
  with	
  different	
  behavior.	
  
Lots	
  of	
  supliers	
  for	
  the	
  same	
  sensor	
  category.	
  
Some	
  sensors	
  are	
  sokware	
  only	
  –	
  they	
  are	
  modelling	
  the	
  reality	
  by	
  using	
  
other	
  sensors	
  (accelera2on	
  etc.).	
  
	
  
	
  	
   	
   	
   	
   	
  Source:	
  EE	
  Times	
  
SENSORS
Access	
  to	
  the	
  set	
  of	
  available	
  sensors	
  is	
  provided	
  by	
  the	
  SensorFramework.	
  
The	
  sensor	
  support	
  started	
  to	
  be	
  quite	
  complete	
  from	
  API	
  9	
  (Android	
  2.3).	
  
	
  	
  
SensorEventListener:	
  
•  	
  onAccurayChanged	
  
•  	
  onSensorChanged	
  
	
  SensorEvent	
  provides	
  the	
  new	
  set	
  of	
  data	
  (sensor	
  specific)	
  
	
  	
  
SENSORS
Sensors	
  are	
  also	
  used	
  to	
  detect/infer	
  user	
  behavior:	
  
Significant	
  Mo2on	
  Sensor	
  (SensorManager):	
  „A	
  significant	
  mo1on	
  is	
  a	
  mo1on	
  
that	
  might	
  lead	
  to	
  a	
  change	
  in	
  the	
  user's	
  loca1on;	
  for	
  example	
  walking,	
  biking,	
  
or	
  si@ng	
  in	
  a	
  moving	
  car.“	
  
	
  
mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION);
mTriggerEventListener = new TriggerEventListener() {
@Override
public void onTrigger(TriggerEvent event) {
// Do work
}
};
mSensorManager.requestTriggerSensor(mTriggerEventListener, mSensor);
SENSORS
Google	
  Play	
  –	
  2013:	
  new	
  AcEvity	
  RecogniEon	
  feature	
  to	
  provide	
  a	
  best	
  guess	
  
of	
  the	
  current	
  user	
  ac2vity.	
  Based	
  on	
  sensor	
  input.	
  
•  ON_FOOT	
  
•  IN_VEHICLE	
  
•  ON_BYCICLE	
  
•  STILL	
  
•  TILTING	
  
•  New:	
  Running,	
  Walking	
  
Generates	
  results	
  with	
  a	
  probability.	
  
Low	
  power	
  implementa2on	
  –	
  may	
  be	
  used	
  instead	
  of	
  „homegrown“	
  solu2ons	
  
based	
  on	
  raw	
  sensor	
  data.	
  
	
  
	
  
ANDROID LOCATION MANAGER
Loca2on	
  Manager	
  used	
  to	
  be	
  the	
  central	
  instance	
  to	
  receive	
  Loca2on	
  info	
  
•  GPS	
  
•  Cell-­‐ID	
  
•  WLAN	
  
•  Support	
  from	
  API	
  1	
  
•  No	
  Play	
  Store	
  lib	
  needed	
  
•  App	
  needs	
  to	
  ask	
  explicitly	
  
•  Some	
  calc	
  voodoo	
  needed	
  	
  
	
  
ADDING SOME SENSOR INFO
By	
  adding	
  addi2onal	
  help	
  from	
  the	
  sensors	
  one	
  might	
  be	
  able	
  to	
  be_er	
  guess	
  
or	
  actually	
  know	
  the	
  current	
  loca2on	
  
HOMEBREW LOCATION SOLUTION
By	
  using	
  all	
  of	
  the	
  shown	
  loca2on	
  provider	
  sources	
  it	
  is	
  possible	
  to	
  get	
  a	
  quite	
  
op2mized	
  loca2on	
  informa2on.	
  
Lots	
  of	
  needed	
  support	
  code	
  
Op2mizing	
  the	
  bets	
  prac2ce	
  parameters	
  done	
  by	
  app	
  developer	
  
	
  Parameters	
  might	
  be	
  different	
  on	
  other	
  hardware	
  	
  
	
  It	
  is	
  important	
  to	
  check	
  for	
  availability	
  of	
  each	
  provider	
  first	
  
	
  Essen2al	
  to	
  cope	
  with	
  ongoing	
  status	
  changes	
  (offline/online,	
  on/off)	
  
	
  
For	
  most	
  devices	
  there	
  is	
  an	
  alterna2ve:	
  Fused	
  Loca2on	
  Provider	
  
FUSED LOCATION PROVIDER
The	
  Fused	
  LocaEon	
  Provider	
  merges	
  the	
  available	
  sources	
  into	
  one	
  single	
  
source:	
  
•  GPS	
  
•  Cell-­‐ID	
  
•  WLAN	
  
•  Sensors	
  
•  Part	
  of	
  the	
  Google	
  Play	
  package	
  
•  Not	
  available	
  on	
  all	
  devices!	
  
•  If	
  there	
  is	
  a	
  Play	
  Store	
  app,	
  there	
  is	
  the	
  Play	
  package	
  
•  Cumbersome	
  process	
  to	
  add	
  into	
  a	
  rooted	
  device.....	
  
FUSED LOCATION PROVIDER
FUSED LOCATION PROVIDER
locRequest	
  =	
  Loca2onRequest.create()	
  
	
  .setPriority	
  (Loca2onRequest.BALANCED_POWER_ACCURACY)	
  
	
  	
  .setInterval(10000)	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  	
  //	
  10s	
  
	
  	
  .setExpira2onDura2on	
  (120000)	
  	
  	
  	
  	
  	
  	
  //	
  stop	
  aker	
  2	
  min	
  from	
  NOW	
  
	
  .setSmallestDisplacement	
  (25) 	
  //	
  25m	
  min.	
  movement	
  for	
  update 	
  	
  
	
  .setNumUpdates	
  (5) 	
   	
  //	
  stop	
  aker	
  3	
  updates	
  
	
  
mLoca2onClient.requestLoca2onUpdates	
  (locRequest,	
  this) 	
  	
  
	
  
FUSED LOCATION PROVIDER
Loca2onClient	
  needs	
  to	
  implement	
  
	
  
•  GooglePlayServicesClient.ConnecEonCallbacks	
  
•  GooglePlayServices.onConnecEonFailedListener	
  
•  LocaEonListner	
  
	
  
Callbacks:	
  
•  onConnected	
  
•  onDisconnected	
  
•  onConnecEonFailed	
  
•  onLocaEonChanged	
  
FUSED LOCATION PROVIDER
Priority	
  op2ons	
  and	
  power	
  drain	
  impact	
  (Source:	
  Google,	
  Galaxy	
  Nexus):	
  
Priority	
   Interval	
   Drain	
  (%	
  per	
  h)	
   Accuracy	
  
HIGH_ACCURACY	
   5s	
   7.25%	
   ~10m	
  
BALANCED_POWER	
   20s	
   0.6%	
   ~40m	
  
NO_POWER	
   N/A	
   small	
   ~Cell	
  related	
  
FUSED LOCATION PROVIDER
I	
  am	
  here!	
  No,	
  i	
  moved	
  a	
  bit.	
  Now	
  i	
  am	
  here.	
  Wait,	
  i	
  am	
  there.	
  
	
  
FUSED LOCATION PROVIDER
Always	
  check	
  the	
  accuracy	
  value	
  of	
  ANY	
  result	
  before	
  any	
  further	
  ac2on.	
  Even	
  
if	
  you	
  get	
  a	
  7	
  digit	
  value	
  you	
  may	
  s2ll	
  be	
  off	
  quite	
  a	
  bit.	
  
	
  
GEOFENCES
A	
  GeoFence	
  is	
  just	
  a	
  radial	
  area,	
  defined	
  by	
  the	
  loca2on	
  center	
  and	
  the	
  
radius.	
  As	
  a	
  result	
  we	
  get	
  a	
  virtual	
  radial	
  fence.	
  
	
  
GEOFENCES – OLD STYLE
Homebrew	
  version	
  -­‐	
  How	
  one	
  had	
  to	
  do	
  it	
  before(based	
  on	
  
Loca2onManager):	
  
	
  
Intent intent = new Intent(PROX_ALERT_INTENT);
PendingIntent proximityIntent = PendingIntent.getBroadcast(this,
intentnum, intent, 0);
locationManager.addProximityAlert(
latitude, longitude,
POINT_RADIUS,
PROX_ALERT_EXPIRATION, proximityIntent)
....
GEOFENCES – OLD STYLE
While	
  the	
  old	
  style	
  might	
  look	
  good	
  it	
  had	
  one	
  major	
  drawback:	
  	
  
It	
  is	
  using	
  way	
  to	
  much	
  ba_ery	
  power.	
  
Reason:	
  No	
  control	
  over	
  loca2on	
  request	
  update	
  parameters	
  like	
  update	
  
frequency	
  or	
  provider!	
  
The	
  default	
  implementa2on	
  result	
  in	
  constant	
  queries	
  and	
  your	
  ba_ery	
  will	
  
be	
  cozy	
  and	
  warm	
  –	
  and	
  soon	
  empty.	
  
Solu2on:	
  	
  Implement	
  your	
  own	
  GeoFence	
  checker	
  using	
  onLocaEonChanged	
  
and	
  some	
  math	
  (it‘s	
  just	
  points	
  and	
  circles)	
  and	
  issue	
  an	
  Intent	
  yourself	
  with	
  
LocaEonManager.KEY_PROXIMITY_ENTERING	
  etc.	
  
	
  
GEOFENCES
Now	
  Google	
  Play	
  Services	
  provide	
  a	
  new	
  GeoFence	
  feature.	
  Just	
  some	
  easy	
  steps:	
  
Define	
  the	
  central	
  loca2on	
  of	
  the	
  GeoFence.	
  
Then	
  add	
  the	
  trigger	
  event	
  you	
  like:	
  
•  	
   entering	
  
•  	
   leaving	
  
•  	
   both	
  
Add	
  a	
  lifespan	
  (up	
  to	
  6	
  days)	
  
Limit	
  of	
  100	
  concurrently	
  ac2ve	
  GeoFences	
  on	
  Android	
  
	
  
Aker	
  ac2va2on	
  the	
  GeoFence	
  trigger	
  will	
  be	
  able	
  to	
  start	
  your	
  app	
  (running	
  in	
  background)	
  to	
  do	
  
whatever	
  you	
  like.	
  
No	
  need	
  to	
  watch	
  loca2on	
  updates	
  yourself	
  
Power	
  footprint	
  op2mized.	
  
	
  Google:	
  1/3	
  of	
  addProximityAlert()	
  
	
  
	
  
BEACONS
Everyone	
  talks	
  about	
  iBeacons™	
  these	
  days	
  as	
  THE	
  indoor	
  loca2on	
  enabler.	
  
Apple	
  ™	
  trademarked	
  the	
  term.	
  Lets	
  talk	
  about	
  Beacons	
  then...	
  
	
  
Basic	
  technology:	
  	
  
	
  Bluetooth	
  Low	
  Energy	
  (BLE)	
  	
  
	
   	
  Bluetooth	
  Smart	
  NOT	
  compa2ble	
  with	
  „normal“	
  BT	
  
	
   	
  Bluetooth	
  Smart	
  Ready	
  (dual	
  mode)	
  	
  
	
  GATT	
  (Generic	
  A_ribute	
  Profile)	
  
	
   	
  send	
  short	
  a_ributes/data	
  packets	
  with	
  specific	
  UUID	
  
	
  Two	
  connec2on	
  roles	
  
	
   	
  Central	
  
	
   	
  Peripheral	
  
	
  Two	
  communica2on	
  roles	
  
	
   	
  Server	
  
	
   	
  Client	
  
BEACONS
A	
  central	
  role	
  BLE	
  device	
  is	
  able	
  to	
  scan	
  for	
  other	
  devices	
  
A	
  peripheral	
  device	
  sends	
  out	
  „adver2sements“	
  	
  
A	
  Server	
  send	
  out	
  data	
  –	
  a	
  client	
  receives	
  it	
  
	
  Blood	
  pressure	
  device	
  is	
  a	
  peripheral	
  and	
  a	
  server	
  
	
  Android	
  device	
  is	
  the	
  central	
  device	
  and	
  the	
  data	
  client	
  
BEACONS
BEACONS
TI	
  SensorTag	
  
	
  -­‐iBeacon	
  support	
  with	
  license	
  
	
  	
  
BEACONS
BEACONS
IBEACONS
To	
  use	
  BLE	
  for	
  indoor	
  purposes,	
  loca2on	
  etc	
  in	
  iBeacon	
  mode:	
  
Device	
  needs	
  to	
  be	
  in	
  adver2se	
  mode	
  to	
  periodically	
  sending	
  out	
  data	
  
	
  20ms	
  ..	
  10s	
  	
  
Data:	
  47	
  byte	
  packages	
  including	
  (in	
  PDU	
  data	
  part	
  –	
  32	
  byte)	
  
	
  UUID 	
   	
  unique	
  ID	
  (hopefully)	
  
	
  Major 	
   	
  group	
  ID	
  
	
  Minor 	
   	
  individual	
  ID	
  
	
  TX	
  power	
  level	
  
	
  
Apple	
  requires	
  hardware	
  vendors	
  to	
  be	
  a	
  licensee:	
  
h_p://mfi.apple.com/ 	
  	
  
IBEACONS
Source:	
   	
  
h_p://www.havlena.net/en/loca2on-­‐technologies/ibeacons-­‐how-­‐do-­‐they-­‐technically-­‐work/	
  
BEACONS
Indoor	
  loca2on:	
  
To	
  measure	
  the	
  distance	
  between	
  the	
  smartphone	
  and	
  an	
  adver2sing	
  beacon	
  
we	
  use	
  the	
  received	
  signal	
  strength	
  indica2on	
  (RSSI)	
  	
  
The	
  TX	
  value	
  is	
  the	
  signal	
  strength	
  1m	
  away	
  –	
  used	
  as	
  the	
  reference.	
  
To	
  get	
  the	
  posi2on	
  we	
  need	
  2+	
  beacons	
  and	
  triangula2on.	
  
	
  
Nice	
  star2ng	
  point	
  for	
  android	
  devs:	
  
h_ps://github.com/RadiusNetworks/android-­‐ibeacon-­‐service	
  
	
  
BEACONS
Support	
  on	
  Android	
  device	
  just	
  about	
  to	
  start.	
  Only	
  a	
  few	
  devices	
  have	
  it!	
  
OS	
  minimum:	
  iOS	
  5+,	
  Windows	
  Phone	
  8+,	
  Android	
  4.3+,	
  BB	
  10	
  
	
  
Check	
  for	
  it:	
  
<uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN“/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required=“false"/>
PackageManager pm = ctx.getPackageManager();
boolean hasBLE = pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE);
uses-­‐feature	
  false?	
  	
  !	
  app	
  will	
  install	
  on	
  all	
  devices.	
  Use	
  the	
  PM	
  at	
  run2me	
  to	
  
access	
  the	
  feature	
  anyways	
  
DEMO
IOT
The	
  Internet	
  of	
  Things	
  is	
  –	
  at	
  least	
  for	
  the	
  mobile	
  device	
  -­‐	
  just	
  a	
  wild	
  bunch	
  of	
  
„somewhat	
  ac2ve	
  tech“,	
  which	
  may	
  be	
  able	
  to	
  communicate.	
  	
  
Is	
  it?	
  
IoT	
  device	
  may	
  communicate	
  with	
  the	
  smartphone	
  too!	
  
They	
  just	
  need	
  to	
  sit	
  on	
  common	
  communica2on	
  protocols.	
  	
  
	
  BLE,	
  NFC,	
  WLAN,	
  Radio...	
  
Since	
  one	
  may	
  know	
  the	
  loca2on	
  of	
  an	
  IoT	
  device	
  in	
  the	
  scanned	
  area	
  you	
  will	
  
get	
  one	
  more	
  loca2on	
  provider.	
  	
  	
  
IOT
BLE	
  enabled	
  Arduino	
  devices	
  
(Cortado	
  etc.)	
  
	
  
	
  
	
  
WLAN	
  enabled	
  Arduino	
  devices	
  
(Sparc	
  Core)	
  
	
  
NFC
Even	
  NFC	
  could	
  be	
  used	
  for	
  loca2on	
  purposes	
  
	
  The	
  NFC	
  tag	
  may	
  hold	
  loca2on	
  data	
  (GeoHash	
  etc)	
  
	
  user	
  needs	
  to	
  be	
  very	
  close	
  to	
  the	
  tag	
  
USE CASES
1.)	
  User	
  walks	
  by	
  a	
  store	
  and	
  receives	
  an	
  mighty	
  coupon	
  
10000	
  mile	
  view:	
  
•  Loca2on	
  info	
  for	
  store	
  
•  App	
  checking	
  the	
  loca2on	
  info	
  
•  App	
  asking	
  the	
  server	
  what	
  to	
  do/or	
  just	
  knowing	
  (eventAPI)	
  what	
  to	
  do	
  
•  App	
  showing	
  the	
  coupon	
  
•  User	
  trades	
  coupon	
  for	
  goods	
  
•  Coupon	
  is	
  tracked	
  to	
  user/transac2on	
  and	
  may	
  pay	
  the	
  app	
  developer	
  	
  	
  
	
  
USE CASES
Example	
  of	
  a	
  simple	
  mguAPI	
  Event	
  
	
  
•  API	
  wakes	
  up	
  and	
  ini2ates	
  an	
  Ac2vity	
  view	
  
•  Further	
  ac2on	
  are	
  subject	
  of	
  customiza2on	
  
USE CASES
2.)	
  „The	
  big	
  drawing“	
  enabler	
  
•  You	
  want	
  that	
  one	
  visitor	
  in	
  the	
  stadium	
  gets	
  the	
  big	
  price	
  (like	
  shoo2ng	
  at	
  
the	
  goal	
  during	
  half	
  2me)	
  
•  User	
  enters	
  the	
  GeoFenced	
  stadium	
  
•  App	
  verifies	
  that	
  the	
  loca2on	
  is	
  „inside“	
  
•  App	
  sends	
  a	
  token	
  to	
  the	
  server	
  aker	
  user	
  interac2on	
  
•  Server	
  chooses	
  one	
  token	
  and	
  sends	
  back	
  the	
  winning	
  no2fica2on	
  to	
  the	
  
winner	
  with	
  loca2on	
  based	
  instruc2ons	
  where	
  to	
  meet	
  the	
  contact	
  
person.	
  
•  Winner	
  is	
  able	
  to	
  meet	
  the	
  contact,	
  gets	
  on	
  the	
  field	
  ...	
  
USE CASES
3.)	
  Find	
  your	
  dog	
  
•  Dog	
  is	
  wearing	
  a	
  small	
  GPS/GPRS	
  tag	
  sending	
  out	
  loca2on	
  info	
  when	
  
outside	
  a	
  GeoFence	
  (not	
  an	
  Android	
  app)	
  
•  App	
  receives	
  the	
  alarm	
  data	
  SMS	
  with	
  the	
  loca2on	
  
•  App	
  leads	
  the	
  user	
  to	
  the	
  dogs	
  loca2on	
  by	
  using	
  maps	
  etc.	
  	
  
MATCHINGUU SERVICES
matchinguu	
  provides	
  a	
  comprehensive	
  API	
  library	
  for	
  indoor	
  and	
  outdoor	
  loca2on	
  
•  all	
  possible	
  loca2on	
  providers	
  
•  power	
  management	
  
•  POI	
  management	
  via	
  internal	
  rules,	
  biz	
  logic	
  and	
  backend	
  	
  
matchinguu	
  also	
  provides	
  the	
  eventAPI	
  
•  what	
  to	
  do	
  when	
  an	
  event	
  actually	
  occurs?	
  	
  
•  Manage	
  and	
  market	
  events	
  
matchinguu	
  provides	
  the	
  backend	
  too	
  
•  Support	
  high	
  numbers	
  of	
  POIs,	
  beacons,	
  customers,	
  partners	
  
•  Dashboard	
  access	
  for	
  our	
  partners	
  
MATCHINGUU SERVICES
Indoor	
  loca2on	
  
	
  Heatmap	
  display	
  via	
  dashboard	
  
MATCHINGUU SERVICES
Dashboard	
  
	
  10000	
  mile	
  view	
  onto	
  major	
  data	
  clusters	
  
MATCHINGUU SERVICES
Dashboard	
  
•  Gain	
  access	
  to	
  current	
  stats	
  
•  Op2mize	
  
•  React	
  
•  Steer	
  
MATCHINGUU SERVICES
Coming	
  June	
  2014	
  
ANDROID REFERENCES
Fused	
  Loca2on:	
  
h_p://developer.android.com/training/loca2on/index.html	
  
	
  
Sensors:	
  
h_p://developer.android.com/guide/topics/sensors/sensors_overview.html	
  
h_ps://sokware.intel.com/en-­‐us/ar2cles/developing-­‐sensor-­‐applica2ons-­‐on-­‐intel-­‐atom-­‐
processor-­‐based-­‐android-­‐phones-­‐and-­‐tablets	
  
	
  
Android	
  Source	
  Repo	
  Xref:	
  
h_p://androidxref.com/	
  
	
  
Book:	
  (when	
  you	
  are	
  allowed	
  to	
  take	
  just	
  one	
  single	
  book)	
  
Android	
  Programming	
  –	
  Pushing	
  the	
  Limits	
  (Erik	
  Hellman)	
  -­‐	
  Wiley	
  
	
  
CONTACT:
TECH CONTACT: JUERGEN.FEY@MATCHINGUU.COM
MARKETING : FELIX.HEBERLE@MATCHINGUU.COM
www.matchinguu.com

Contenu connexe

En vedette

Using Qualtrics to Create Automated Online Trainings
Using Qualtrics to Create Automated Online TrainingsUsing Qualtrics to Create Automated Online Trainings
Using Qualtrics to Create Automated Online Trainings
Shalin Hai-Jew
 

En vedette (20)

Data to Go: Mobile API Design (SXSW)
Data to Go: Mobile API Design (SXSW)Data to Go: Mobile API Design (SXSW)
Data to Go: Mobile API Design (SXSW)
 
Building Location-Aware Apps with Open Source & Open Data (SXSW 2015)
Building Location-Aware Apps with Open Source & Open Data (SXSW 2015)Building Location-Aware Apps with Open Source & Open Data (SXSW 2015)
Building Location-Aware Apps with Open Source & Open Data (SXSW 2015)
 
Evolve: InSTEDD's Global Early Warning and Response System
Evolve: InSTEDD's Global Early Warning and Response SystemEvolve: InSTEDD's Global Early Warning and Response System
Evolve: InSTEDD's Global Early Warning and Response System
 
Social Media for the Meta-Leader
Social Media for the Meta-LeaderSocial Media for the Meta-Leader
Social Media for the Meta-Leader
 
Big Data in Public Health
Big Data in Public HealthBig Data in Public Health
Big Data in Public Health
 
Public Health Surveillance Through Collaboration
Public Health Surveillance Through CollaborationPublic Health Surveillance Through Collaboration
Public Health Surveillance Through Collaboration
 
BioSense 2.0
BioSense 2.0BioSense 2.0
BioSense 2.0
 
BioSense Program Going Forward: HIMSS10 Conference
BioSense Program Going Forward: HIMSS10 ConferenceBioSense Program Going Forward: HIMSS10 Conference
BioSense Program Going Forward: HIMSS10 Conference
 
Geohash: Integration of Disparate Geospatial Data
Geohash: Integration of Disparate Geospatial DataGeohash: Integration of Disparate Geospatial Data
Geohash: Integration of Disparate Geospatial Data
 
precisionFDA
precisionFDAprecisionFDA
precisionFDA
 
Latest Advances in Megapixel Surveillance
Latest Advances in Megapixel SurveillanceLatest Advances in Megapixel Surveillance
Latest Advances in Megapixel Surveillance
 
GeoSpatially enabling your Spark and Accumulo clusters with LocationTech
GeoSpatially enabling your Spark and Accumulo clusters with LocationTechGeoSpatially enabling your Spark and Accumulo clusters with LocationTech
GeoSpatially enabling your Spark and Accumulo clusters with LocationTech
 
Riff: A Social Network and Collaborative Platform for Public Health Disease S...
Riff: A Social Network and Collaborative Platform for Public Health Disease S...Riff: A Social Network and Collaborative Platform for Public Health Disease S...
Riff: A Social Network and Collaborative Platform for Public Health Disease S...
 
[FOSS4G Korea 2016] GeoHash를 이용한 지형도 변화탐지와 시계열 관리
[FOSS4G Korea 2016] GeoHash를 이용한 지형도 변화탐지와 시계열 관리[FOSS4G Korea 2016] GeoHash를 이용한 지형도 변화탐지와 시계열 관리
[FOSS4G Korea 2016] GeoHash를 이용한 지형도 변화탐지와 시계열 관리
 
Understanding Public Sentiment: Conducting a Related-Tags Content Network Ext...
Understanding Public Sentiment: Conducting a Related-Tags Content Network Ext...Understanding Public Sentiment: Conducting a Related-Tags Content Network Ext...
Understanding Public Sentiment: Conducting a Related-Tags Content Network Ext...
 
Using Qualtrics to Create Automated Online Trainings
Using Qualtrics to Create Automated Online TrainingsUsing Qualtrics to Create Automated Online Trainings
Using Qualtrics to Create Automated Online Trainings
 
Epi Info™ Mesh4x
Epi Info™ Mesh4xEpi Info™ Mesh4x
Epi Info™ Mesh4x
 
Writing and Publishing about Applied Technologies in Tech Journals and Books
Writing and Publishing about Applied Technologies in Tech Journals and BooksWriting and Publishing about Applied Technologies in Tech Journals and Books
Writing and Publishing about Applied Technologies in Tech Journals and Books
 
Hashtag Conversations,Eventgraphs, and User Ego Neighborhoods: Extracting So...
Hashtag Conversations,Eventgraphs, and User Ego Neighborhoods:  Extracting So...Hashtag Conversations,Eventgraphs, and User Ego Neighborhoods:  Extracting So...
Hashtag Conversations,Eventgraphs, and User Ego Neighborhoods: Extracting So...
 
Catching imsi catchers
Catching imsi catchersCatching imsi catchers
Catching imsi catchers
 

Similaire à Matchinguu droidcon presentation

Device Abstraction in OSGi Based Embedded Systems - Dimitar Valtchev
Device Abstraction in OSGi Based Embedded Systems - Dimitar ValtchevDevice Abstraction in OSGi Based Embedded Systems - Dimitar Valtchev
Device Abstraction in OSGi Based Embedded Systems - Dimitar Valtchev
mfrancis
 
Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
AbdullahMunir32
 
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
mfrancis
 
A SOFTWARE DEFINED RADIO BASED
A SOFTWARE DEFINED RADIO BASEDA SOFTWARE DEFINED RADIO BASED
A SOFTWARE DEFINED RADIO BASED
ANGELIN JOHN
 

Similaire à Matchinguu droidcon presentation (20)

Location based advertisement system with voice announcement system
Location based advertisement system with voice announcement systemLocation based advertisement system with voice announcement system
Location based advertisement system with voice announcement system
 
NetSim Technology Library- Manets
NetSim Technology Library- ManetsNetSim Technology Library- Manets
NetSim Technology Library- Manets
 
Resume (4)
Resume (4)Resume (4)
Resume (4)
 
Rover technology ppt
Rover technology pptRover technology ppt
Rover technology ppt
 
Indoor navigation system
Indoor navigation systemIndoor navigation system
Indoor navigation system
 
Device Abstraction in OSGi Based Embedded Systems - Dimitar Valtchev
Device Abstraction in OSGi Based Embedded Systems - Dimitar ValtchevDevice Abstraction in OSGi Based Embedded Systems - Dimitar Valtchev
Device Abstraction in OSGi Based Embedded Systems - Dimitar Valtchev
 
Mobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdfMobile Application Development-Lecture 15 & 16.pdf
Mobile Application Development-Lecture 15 & 16.pdf
 
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
Leveraging the strength of OSGi to deliver a convergent IoT Ecosystem - O Log...
 
A SOFTWARE DEFINED RADIO BASED
A SOFTWARE DEFINED RADIO BASEDA SOFTWARE DEFINED RADIO BASED
A SOFTWARE DEFINED RADIO BASED
 
Garbage Management using Android Smartphone
Garbage Management using Android SmartphoneGarbage Management using Android Smartphone
Garbage Management using Android Smartphone
 
Introduction to FIWARE Open Ecosystem
Introduction to FIWARE Open EcosystemIntroduction to FIWARE Open Ecosystem
Introduction to FIWARE Open Ecosystem
 
Smart parking system using IOT
Smart parking system using IOTSmart parking system using IOT
Smart parking system using IOT
 
New Framework for Improving Bigdata Analaysis Using Mobile Agent
New Framework for Improving Bigdata Analaysis Using Mobile AgentNew Framework for Improving Bigdata Analaysis Using Mobile Agent
New Framework for Improving Bigdata Analaysis Using Mobile Agent
 
13 9246 it implementation of cloud connected (edit ari)
13 9246 it implementation of cloud connected (edit ari)13 9246 it implementation of cloud connected (edit ari)
13 9246 it implementation of cloud connected (edit ari)
 
IRJET- Implementation of Cloud Robotics using Raspberry PI to Monitor Product...
IRJET- Implementation of Cloud Robotics using Raspberry PI to Monitor Product...IRJET- Implementation of Cloud Robotics using Raspberry PI to Monitor Product...
IRJET- Implementation of Cloud Robotics using Raspberry PI to Monitor Product...
 
Internet of things, and rise of ibeacons
Internet of things, and rise of ibeaconsInternet of things, and rise of ibeacons
Internet of things, and rise of ibeacons
 
Synapseindia android application development tutorial
Synapseindia android application development tutorialSynapseindia android application development tutorial
Synapseindia android application development tutorial
 
Synapseindia android apps development tutorial
Synapseindia android apps  development tutorialSynapseindia android apps  development tutorial
Synapseindia android apps development tutorial
 
IoT Communication protocols Overview
IoT Communication protocols OverviewIoT Communication protocols Overview
IoT Communication protocols Overview
 
LORA BASED DATA ACQUISITION SYSTEM
LORA BASED DATA ACQUISITION SYSTEMLORA BASED DATA ACQUISITION SYSTEM
LORA BASED DATA ACQUISITION SYSTEM
 

Plus de Droidcon Berlin

Droidcon de 2014 google cast
Droidcon de 2014   google castDroidcon de 2014   google cast
Droidcon de 2014 google cast
Droidcon Berlin
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
Droidcon Berlin
 
Android industrial mobility
Android industrial mobility Android industrial mobility
Android industrial mobility
Droidcon Berlin
 
From sensor data_to_android_and_back
From sensor data_to_android_and_backFrom sensor data_to_android_and_back
From sensor data_to_android_and_back
Droidcon Berlin
 
new_age_graphics_android_x86
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86
Droidcon Berlin
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
Droidcon Berlin
 
Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3
Droidcon Berlin
 
The artofcalabash peterkrauss
The artofcalabash peterkraussThe artofcalabash peterkrauss
The artofcalabash peterkrauss
Droidcon Berlin
 
Raesch, gries droidcon 2014
Raesch, gries   droidcon 2014Raesch, gries   droidcon 2014
Raesch, gries droidcon 2014
Droidcon Berlin
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
Droidcon Berlin
 
20140508 quantified self droidcon
20140508 quantified self droidcon20140508 quantified self droidcon
20140508 quantified self droidcon
Droidcon Berlin
 
Tuning android for low ram devices
Tuning android for low ram devicesTuning android for low ram devices
Tuning android for low ram devices
Droidcon Berlin
 
Froyo to kit kat two years developing & maintaining deliradio
Froyo to kit kat   two years developing & maintaining deliradioFroyo to kit kat   two years developing & maintaining deliradio
Froyo to kit kat two years developing & maintaining deliradio
Droidcon Berlin
 
Droidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicroDroidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicro
Droidcon Berlin
 
Droidcon2013 commercialsuccess rannenberg
Droidcon2013 commercialsuccess rannenbergDroidcon2013 commercialsuccess rannenberg
Droidcon2013 commercialsuccess rannenberg
Droidcon Berlin
 

Plus de Droidcon Berlin (20)

Droidcon de 2014 google cast
Droidcon de 2014   google castDroidcon de 2014   google cast
Droidcon de 2014 google cast
 
Android programming -_pushing_the_limits
Android programming -_pushing_the_limitsAndroid programming -_pushing_the_limits
Android programming -_pushing_the_limits
 
crashing in style
crashing in stylecrashing in style
crashing in style
 
Raspberry Pi
Raspberry PiRaspberry Pi
Raspberry Pi
 
Android industrial mobility
Android industrial mobility Android industrial mobility
Android industrial mobility
 
Details matter in ux
Details matter in uxDetails matter in ux
Details matter in ux
 
From sensor data_to_android_and_back
From sensor data_to_android_and_backFrom sensor data_to_android_and_back
From sensor data_to_android_and_back
 
droidparts
droidpartsdroidparts
droidparts
 
new_age_graphics_android_x86
new_age_graphics_android_x86new_age_graphics_android_x86
new_age_graphics_android_x86
 
5 tips of monetization
5 tips of monetization5 tips of monetization
5 tips of monetization
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
 
Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3Cgm life sdk_droidcon_2014_v3
Cgm life sdk_droidcon_2014_v3
 
The artofcalabash peterkrauss
The artofcalabash peterkraussThe artofcalabash peterkrauss
The artofcalabash peterkrauss
 
Raesch, gries droidcon 2014
Raesch, gries   droidcon 2014Raesch, gries   droidcon 2014
Raesch, gries droidcon 2014
 
Android open gl2_droidcon_2014
Android open gl2_droidcon_2014Android open gl2_droidcon_2014
Android open gl2_droidcon_2014
 
20140508 quantified self droidcon
20140508 quantified self droidcon20140508 quantified self droidcon
20140508 quantified self droidcon
 
Tuning android for low ram devices
Tuning android for low ram devicesTuning android for low ram devices
Tuning android for low ram devices
 
Froyo to kit kat two years developing & maintaining deliradio
Froyo to kit kat   two years developing & maintaining deliradioFroyo to kit kat   two years developing & maintaining deliradio
Froyo to kit kat two years developing & maintaining deliradio
 
Droidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicroDroidcon2013 security genes_trendmicro
Droidcon2013 security genes_trendmicro
 
Droidcon2013 commercialsuccess rannenberg
Droidcon2013 commercialsuccess rannenbergDroidcon2013 commercialsuccess rannenberg
Droidcon2013 commercialsuccess rannenberg
 

Matchinguu droidcon presentation

  • 1. LOCATION BASED SOLUTIONS IN THE ANDROID REALMThere are many ways to Rome, some may look quite surprising Jürgen Fey . CTO matchinguu
  • 2. AGENDA •  Matchinguu  backgrounder   •  Loca2on  Provider  Technologies  for  Android  devices   •  Use  cases    
  • 3. SOME INFO ABOUT US WE ARE THE EXPERT FOR ”LOCATION BASED SOLUTIONS” WITH THE CLEAR FOCUS ON MOBILE. matchinguu  is  a  startup  based  in  Munich,   Germany  (headcount:  9+).  We  started  in  2013   with  a  clear  target:   matchinguu  is  providing  a  comprehensive  API  for   Android  and  iOS  as  well  as  the  needed  backend   services  and  hardware  infrastructure  to  allow   businesses  to  integrate  even  complex  LBS   scenarios  fast.     Yes,  we  also  built  complete,  custom  apps.                        
  • 4. OUR SERVICES ANDROID API Easy  to  integrate  API  for   various  loca2on   providers.  Event  system.   Power  management.       iOS API Easy  to  integrate  API  for   various  loca2on   providers.  Event  system.   Power  management.      BACKEND SaaS Customer  dashboard  to   control  loca2ons  and   events.  Heatmaps,  Process   automa2on,  repor2ng  and   more…       HARDWARE Local  hotspot,  business   intelligence,  Beacons,   Backend  adapters  and   more  .    
  • 5. LOCATION PROVIDERS ON MOBILE PLATFORMS CELL-ID WLAN GPS FUSED LOCATION PROVIDER GEOHASH SENSORS GEOFENCES BEACONS IOT NFC Many  op(ons   The  mobile  plaSorm  (Android)   provides  a  wide  range  of  LBS   op2ons.       Combine  and/or  use  wisely   While  one  might  be  tempted  to   use  the  best  providers  at  any  given   2me  just  to  be  save  the  user  will   not  tolerate  the  resul2ng  power   drain.  
  • 6. CELL-ID If  the  mobile  device  is  connected  to  a  network  cell  (through  the  modem  part)   the  „Cell-­‐ID“  provides  a  clear  loca2on  fingerprint   •  The  network  base  sta2ons  (Base  Transceiver  Sta2on,  Cell)  are  sta2c   loca2on  reference  points   •  The  loca2ons  are  known  to  the  providers,  Google  and  other  service   providers   •  Triangula2on  allows  one  to  guess  a  loca2on  with  smaller  error  burden   Accuracy:  From  <  100m  to  >  20  km     Public  Cell-­‐ID  databases      OpenCellID  (h_p://wiki.opencellid.org/wiki/API)    unwiredlabs  Loca2onAPI    (h_p://unwiredlabs.com/)    
  • 7. CELL-ID Use  TelephonyManager  to  retrieve  current     •  CellID   •  MNC  (Mobile  Network  Code)   •  MCC  (Mobile  Country  Code)   •  LAC  (Loca2on  Area  Code)     Use  PhoneStateListener  and  onCellInfoChanged  callback  to  retrieve  new  Cell-­‐ID   info  (device  must  be  awake!  wakelock)     Power  Factor:  very  low,  for  constant  background  updates  higher     Android  Reference:     h_p://developer.android.com/reference/android/telephony/CellLoca2on.html    
  • 8. CELL-ID Example     TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); GsmCellLocation cellLocation = (GsmCellLocation)tManager.getCellLocation(); String networkOperator = tManager.getNetworkOperator(); String mcc = networkOperator.substring(0, 3); String mnc = networkOperator.substring(3); int cid = cellLocation.getCid(); int lac = cellLocation.getLac();
  • 9. CELL-ID Nice  Android  appS:     •  OpenSignal   •  Cell  WIDGET  
  • 10. CELL-ID Sidenote:   By  using  an  IMSI  catcher  (you  might  Google  for  that  one...)  an  en2ty  other   than  the  official  provider  may  „provide“  you  with  an  alterna2ve  Cell,  which   takes  over  the  task  of  network  connec2vity.       IMSI  catcher  detec2on:     h_p://forum.xda-­‐developers.com/showthread.php?t=1422969    
  • 11. WLAN The  WLAN  signal  is  a  perfect  reference  for  quite  accurate  loca2on  info.   How  does  Google  get  this  valuable  info?    It´s  YOU!     Add  the  following  ingredients  to  the  sweet  cake:   •  Android  Device   •  GPS  and  other  Loca2on  Providers   •  Network  connec2on   No  need  to  use  Maps  etc  –  they  do  it  anyways  (occasionally,  anonymously)   BTW:  Apple,  Microsok  et  al  are  working  the  same  way   Public  Database:  h_p://www.openwlanmap.org/  
  • 12. WLAN Each  WLAN  Access  Point  can  be  defined  by     •  SSID  (Service  Set  Iden2fier)   •  MAC  Address  (unique  network  hardware  address)   By  merging  the  info  about  an  SSID  and  all  other  Loca2on  Providers  (when  available)  it  is   possible  to  build  up  a  Loca2on  Database  using  just  SSIDs.     This  is  what  is  happening  –  each  SSID  can/may  be  used  for  Loca2on  info       Known  SSIDs  can  be  used  for  inhouse  apps  (Custom  WLAN  Proximity)         Power  Factor:  high  when  always  on,  „manageable“  for  proximity  use  case   Android  Tutorial:  h_p://www.tutorialspoint.com/android/android_wi_fi.htm      
  • 13. GEOHASH GeoHashing  is  using  a  specially  prepared  text  info  for  high  accurary  loca2on.   A  single  GeoHash  string  provides  info  for  a  two  coordinate  loca2on   Depending  on  the  string  length  the  accuracy  increases   8  characters:    38/19m   12  characters:  4/2  cm             h_p://unterbahn.com/2009/11/metric-­‐dimensions-­‐of-­‐geohash-­‐par22ons-­‐at-­‐the-­‐equator/  
  • 16. GEOHASH Example:  h_p://geohash.org/u33d8m58g      (Gleisdreieck  Berlin)   Some  databases  support  GeoHashing  (MongoDB,  SOLR  etc.)     Matchinguu  uses  the  GeoHash  info  as  part  of  the  SSID  for  customer  APs       SSID:  „magic_u33d8m58g_zH232J_powered  by  matchinguu“     Anyone  interested  to  provide  an  open  source  repo  for  such  kind  of  locSSID?  (lets   talk)     Nice  demo:  h_p://geohash.gofreerange.com/      
  • 17. GPS The  „bread-­‐and-­‐bu_er“  Loca2on  provider.     Dedicated  GPS  hardware   Accuracy  for  public  uses  cases:  down  to  3m   Update  rate:  down  to  1s   TTFF  (Time  To  First  Fix):  may  take  loooong    needs  to  „see“  at  least  3  satellites  –  the  more  the  be_er    usually  in  less  than  a  minute,  but  s2ll  ...   Power  Factor:  very  high    (80..150  mA)     Android  Example:   h_p://www.codeproject.com/Ar2cles/665527/A-­‐GPS-­‐Loca2on-­‐Ploqng-­‐Android-­‐ Applica2on        
  • 18. GPS For  GPS  and  any  other  loca2on  providers:   Use  BroadcastReceiver  or  Service  with  LocaEonListener  to  set  up  true   background  processing.   BroadcastReceiver:  Android  adds  your  receiver  during  boot  2me  (if  listed  in   Manifest).  Quite  nice  for  apps  working  in  background.     Alterna2ve:  Register  during  run2me  and  send  an  PendingIndent  .  This  is   be_er  when  you  need  to  cope  with  states.     Service:  Generally  a  bit  heavier  but  s2ll  also  ok.  
  • 19. GPS Unofficial  features:   <uses-permission android:name=„android.permission.ACCESS_LOCATION_EXTRACOMMANDS“ />     http://androidxref.com/  
  • 20. GPS When  used  wisely,  GPS  is  a  top  notch  provider  for  accurate  loca2on   informa2on  –  use  it  wisely  and  only  when  needed  and  you  are  save.   Do  not  use  it  as  the  sole  source,  if  possible.   Always  keep  the  power  consump2on  in  mind.   GPS  must  be  turned  on  –  in  case  you  need  to  ask  the  user  to  ac2vate.  
  • 21. SENSORS Sensors  are  playing  an  increasingly  important  role  when  dealing  with  loca2on-­‐aware  solu2ons.     They  may  be  used  to  help  „guessing“  movements,  hence  a  new  loca2on  –  or  just  to  reduce  power   consump2on.     There  are  three  general  sensor  groups  supported  by  Android:   •  Mo2on  sensors   •  Accelerometer   •  Gravity   •  Gyroscope/Rota2onal  Vector   •  Environmental  sensors   •  Temperatur   •  Light/Sound   •  Air  Pressure/Humidity   •  Posi2on  sensors   •  Orienta2on   •  Magnetometer  
  • 22. SENSORS The  number  of  available  sensors,  their  capabili2es  and  accuracy  does  vary!   There  is  no  thing  as  a  generic  sensor  in  each  category.   There  might  be  mul2ple  sensors  per  category  –  with  different  behavior.   Lots  of  supliers  for  the  same  sensor  category.   Some  sensors  are  sokware  only  –  they  are  modelling  the  reality  by  using   other  sensors  (accelera2on  etc.).                Source:  EE  Times  
  • 23. SENSORS Access  to  the  set  of  available  sensors  is  provided  by  the  SensorFramework.   The  sensor  support  started  to  be  quite  complete  from  API  9  (Android  2.3).       SensorEventListener:   •   onAccurayChanged   •   onSensorChanged    SensorEvent  provides  the  new  set  of  data  (sensor  specific)      
  • 24. SENSORS Sensors  are  also  used  to  detect/infer  user  behavior:   Significant  Mo2on  Sensor  (SensorManager):  „A  significant  mo1on  is  a  mo1on   that  might  lead  to  a  change  in  the  user's  loca1on;  for  example  walking,  biking,   or  si@ng  in  a  moving  car.“     mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_SIGNIFICANT_MOTION); mTriggerEventListener = new TriggerEventListener() { @Override public void onTrigger(TriggerEvent event) { // Do work } }; mSensorManager.requestTriggerSensor(mTriggerEventListener, mSensor);
  • 25. SENSORS Google  Play  –  2013:  new  AcEvity  RecogniEon  feature  to  provide  a  best  guess   of  the  current  user  ac2vity.  Based  on  sensor  input.   •  ON_FOOT   •  IN_VEHICLE   •  ON_BYCICLE   •  STILL   •  TILTING   •  New:  Running,  Walking   Generates  results  with  a  probability.   Low  power  implementa2on  –  may  be  used  instead  of  „homegrown“  solu2ons   based  on  raw  sensor  data.      
  • 26. ANDROID LOCATION MANAGER Loca2on  Manager  used  to  be  the  central  instance  to  receive  Loca2on  info   •  GPS   •  Cell-­‐ID   •  WLAN   •  Support  from  API  1   •  No  Play  Store  lib  needed   •  App  needs  to  ask  explicitly   •  Some  calc  voodoo  needed      
  • 27. ADDING SOME SENSOR INFO By  adding  addi2onal  help  from  the  sensors  one  might  be  able  to  be_er  guess   or  actually  know  the  current  loca2on  
  • 28. HOMEBREW LOCATION SOLUTION By  using  all  of  the  shown  loca2on  provider  sources  it  is  possible  to  get  a  quite   op2mized  loca2on  informa2on.   Lots  of  needed  support  code   Op2mizing  the  bets  prac2ce  parameters  done  by  app  developer    Parameters  might  be  different  on  other  hardware      It  is  important  to  check  for  availability  of  each  provider  first    Essen2al  to  cope  with  ongoing  status  changes  (offline/online,  on/off)     For  most  devices  there  is  an  alterna2ve:  Fused  Loca2on  Provider  
  • 29. FUSED LOCATION PROVIDER The  Fused  LocaEon  Provider  merges  the  available  sources  into  one  single   source:   •  GPS   •  Cell-­‐ID   •  WLAN   •  Sensors   •  Part  of  the  Google  Play  package   •  Not  available  on  all  devices!   •  If  there  is  a  Play  Store  app,  there  is  the  Play  package   •  Cumbersome  process  to  add  into  a  rooted  device.....  
  • 31. FUSED LOCATION PROVIDER locRequest  =  Loca2onRequest.create()    .setPriority  (Loca2onRequest.BALANCED_POWER_ACCURACY)      .setInterval(10000)                                                            //  10s      .setExpira2onDura2on  (120000)              //  stop  aker  2  min  from  NOW    .setSmallestDisplacement  (25)  //  25m  min.  movement  for  update      .setNumUpdates  (5)    //  stop  aker  3  updates     mLoca2onClient.requestLoca2onUpdates  (locRequest,  this)      
  • 32. FUSED LOCATION PROVIDER Loca2onClient  needs  to  implement     •  GooglePlayServicesClient.ConnecEonCallbacks   •  GooglePlayServices.onConnecEonFailedListener   •  LocaEonListner     Callbacks:   •  onConnected   •  onDisconnected   •  onConnecEonFailed   •  onLocaEonChanged  
  • 33. FUSED LOCATION PROVIDER Priority  op2ons  and  power  drain  impact  (Source:  Google,  Galaxy  Nexus):   Priority   Interval   Drain  (%  per  h)   Accuracy   HIGH_ACCURACY   5s   7.25%   ~10m   BALANCED_POWER   20s   0.6%   ~40m   NO_POWER   N/A   small   ~Cell  related  
  • 34. FUSED LOCATION PROVIDER I  am  here!  No,  i  moved  a  bit.  Now  i  am  here.  Wait,  i  am  there.    
  • 35. FUSED LOCATION PROVIDER Always  check  the  accuracy  value  of  ANY  result  before  any  further  ac2on.  Even   if  you  get  a  7  digit  value  you  may  s2ll  be  off  quite  a  bit.    
  • 36. GEOFENCES A  GeoFence  is  just  a  radial  area,  defined  by  the  loca2on  center  and  the   radius.  As  a  result  we  get  a  virtual  radial  fence.    
  • 37. GEOFENCES – OLD STYLE Homebrew  version  -­‐  How  one  had  to  do  it  before(based  on   Loca2onManager):     Intent intent = new Intent(PROX_ALERT_INTENT); PendingIntent proximityIntent = PendingIntent.getBroadcast(this, intentnum, intent, 0); locationManager.addProximityAlert( latitude, longitude, POINT_RADIUS, PROX_ALERT_EXPIRATION, proximityIntent) ....
  • 38. GEOFENCES – OLD STYLE While  the  old  style  might  look  good  it  had  one  major  drawback:     It  is  using  way  to  much  ba_ery  power.   Reason:  No  control  over  loca2on  request  update  parameters  like  update   frequency  or  provider!   The  default  implementa2on  result  in  constant  queries  and  your  ba_ery  will   be  cozy  and  warm  –  and  soon  empty.   Solu2on:    Implement  your  own  GeoFence  checker  using  onLocaEonChanged   and  some  math  (it‘s  just  points  and  circles)  and  issue  an  Intent  yourself  with   LocaEonManager.KEY_PROXIMITY_ENTERING  etc.    
  • 39. GEOFENCES Now  Google  Play  Services  provide  a  new  GeoFence  feature.  Just  some  easy  steps:   Define  the  central  loca2on  of  the  GeoFence.   Then  add  the  trigger  event  you  like:   •    entering   •    leaving   •    both   Add  a  lifespan  (up  to  6  days)   Limit  of  100  concurrently  ac2ve  GeoFences  on  Android     Aker  ac2va2on  the  GeoFence  trigger  will  be  able  to  start  your  app  (running  in  background)  to  do   whatever  you  like.   No  need  to  watch  loca2on  updates  yourself   Power  footprint  op2mized.    Google:  1/3  of  addProximityAlert()      
  • 40. BEACONS Everyone  talks  about  iBeacons™  these  days  as  THE  indoor  loca2on  enabler.   Apple  ™  trademarked  the  term.  Lets  talk  about  Beacons  then...     Basic  technology:      Bluetooth  Low  Energy  (BLE)        Bluetooth  Smart  NOT  compa2ble  with  „normal“  BT      Bluetooth  Smart  Ready  (dual  mode)      GATT  (Generic  A_ribute  Profile)      send  short  a_ributes/data  packets  with  specific  UUID    Two  connec2on  roles      Central      Peripheral    Two  communica2on  roles      Server      Client  
  • 41. BEACONS A  central  role  BLE  device  is  able  to  scan  for  other  devices   A  peripheral  device  sends  out  „adver2sements“     A  Server  send  out  data  –  a  client  receives  it    Blood  pressure  device  is  a  peripheral  and  a  server    Android  device  is  the  central  device  and  the  data  client  
  • 43. BEACONS TI  SensorTag    -­‐iBeacon  support  with  license      
  • 46. IBEACONS To  use  BLE  for  indoor  purposes,  loca2on  etc  in  iBeacon  mode:   Device  needs  to  be  in  adver2se  mode  to  periodically  sending  out  data    20ms  ..  10s     Data:  47  byte  packages  including  (in  PDU  data  part  –  32  byte)    UUID    unique  ID  (hopefully)    Major    group  ID    Minor    individual  ID    TX  power  level     Apple  requires  hardware  vendors  to  be  a  licensee:   h_p://mfi.apple.com/    
  • 47. IBEACONS Source:     h_p://www.havlena.net/en/loca2on-­‐technologies/ibeacons-­‐how-­‐do-­‐they-­‐technically-­‐work/  
  • 48. BEACONS Indoor  loca2on:   To  measure  the  distance  between  the  smartphone  and  an  adver2sing  beacon   we  use  the  received  signal  strength  indica2on  (RSSI)     The  TX  value  is  the  signal  strength  1m  away  –  used  as  the  reference.   To  get  the  posi2on  we  need  2+  beacons  and  triangula2on.     Nice  star2ng  point  for  android  devs:   h_ps://github.com/RadiusNetworks/android-­‐ibeacon-­‐service    
  • 49. BEACONS Support  on  Android  device  just  about  to  start.  Only  a  few  devices  have  it!   OS  minimum:  iOS  5+,  Windows  Phone  8+,  Android  4.3+,  BB  10     Check  for  it:   <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN“/> <uses-feature android:name="android.hardware.bluetooth_le" android:required=“false"/> PackageManager pm = ctx.getPackageManager(); boolean hasBLE = pm.hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE); uses-­‐feature  false?    !  app  will  install  on  all  devices.  Use  the  PM  at  run2me  to   access  the  feature  anyways  
  • 50. DEMO
  • 51. IOT The  Internet  of  Things  is  –  at  least  for  the  mobile  device  -­‐  just  a  wild  bunch  of   „somewhat  ac2ve  tech“,  which  may  be  able  to  communicate.     Is  it?   IoT  device  may  communicate  with  the  smartphone  too!   They  just  need  to  sit  on  common  communica2on  protocols.      BLE,  NFC,  WLAN,  Radio...   Since  one  may  know  the  loca2on  of  an  IoT  device  in  the  scanned  area  you  will   get  one  more  loca2on  provider.      
  • 52. IOT BLE  enabled  Arduino  devices   (Cortado  etc.)         WLAN  enabled  Arduino  devices   (Sparc  Core)    
  • 53. NFC Even  NFC  could  be  used  for  loca2on  purposes    The  NFC  tag  may  hold  loca2on  data  (GeoHash  etc)    user  needs  to  be  very  close  to  the  tag  
  • 54. USE CASES 1.)  User  walks  by  a  store  and  receives  an  mighty  coupon   10000  mile  view:   •  Loca2on  info  for  store   •  App  checking  the  loca2on  info   •  App  asking  the  server  what  to  do/or  just  knowing  (eventAPI)  what  to  do   •  App  showing  the  coupon   •  User  trades  coupon  for  goods   •  Coupon  is  tracked  to  user/transac2on  and  may  pay  the  app  developer        
  • 55. USE CASES Example  of  a  simple  mguAPI  Event     •  API  wakes  up  and  ini2ates  an  Ac2vity  view   •  Further  ac2on  are  subject  of  customiza2on  
  • 56. USE CASES 2.)  „The  big  drawing“  enabler   •  You  want  that  one  visitor  in  the  stadium  gets  the  big  price  (like  shoo2ng  at   the  goal  during  half  2me)   •  User  enters  the  GeoFenced  stadium   •  App  verifies  that  the  loca2on  is  „inside“   •  App  sends  a  token  to  the  server  aker  user  interac2on   •  Server  chooses  one  token  and  sends  back  the  winning  no2fica2on  to  the   winner  with  loca2on  based  instruc2ons  where  to  meet  the  contact   person.   •  Winner  is  able  to  meet  the  contact,  gets  on  the  field  ...  
  • 57. USE CASES 3.)  Find  your  dog   •  Dog  is  wearing  a  small  GPS/GPRS  tag  sending  out  loca2on  info  when   outside  a  GeoFence  (not  an  Android  app)   •  App  receives  the  alarm  data  SMS  with  the  loca2on   •  App  leads  the  user  to  the  dogs  loca2on  by  using  maps  etc.    
  • 58. MATCHINGUU SERVICES matchinguu  provides  a  comprehensive  API  library  for  indoor  and  outdoor  loca2on   •  all  possible  loca2on  providers   •  power  management   •  POI  management  via  internal  rules,  biz  logic  and  backend     matchinguu  also  provides  the  eventAPI   •  what  to  do  when  an  event  actually  occurs?     •  Manage  and  market  events   matchinguu  provides  the  backend  too   •  Support  high  numbers  of  POIs,  beacons,  customers,  partners   •  Dashboard  access  for  our  partners  
  • 59. MATCHINGUU SERVICES Indoor  loca2on    Heatmap  display  via  dashboard  
  • 60. MATCHINGUU SERVICES Dashboard    10000  mile  view  onto  major  data  clusters  
  • 61. MATCHINGUU SERVICES Dashboard   •  Gain  access  to  current  stats   •  Op2mize   •  React   •  Steer  
  • 63. ANDROID REFERENCES Fused  Loca2on:   h_p://developer.android.com/training/loca2on/index.html     Sensors:   h_p://developer.android.com/guide/topics/sensors/sensors_overview.html   h_ps://sokware.intel.com/en-­‐us/ar2cles/developing-­‐sensor-­‐applica2ons-­‐on-­‐intel-­‐atom-­‐ processor-­‐based-­‐android-­‐phones-­‐and-­‐tablets     Android  Source  Repo  Xref:   h_p://androidxref.com/     Book:  (when  you  are  allowed  to  take  just  one  single  book)   Android  Programming  –  Pushing  the  Limits  (Erik  Hellman)  -­‐  Wiley    
  • 64. CONTACT: TECH CONTACT: JUERGEN.FEY@MATCHINGUU.COM MARKETING : FELIX.HEBERLE@MATCHINGUU.COM www.matchinguu.com