Customize Location Provider
By default, SDK retrieving GPS locations from system location manager, meanwhile, SDK also allows client inject customized location provider such that client side can simulate GPS location more flexibility. Following steps will illustrate how to deal with customized location provider.
Step 1: Implement customized location provider
One just need declare a class inheritance from LocationProvider and implement all interfaces with customized way. Following example code demostrate a location provider only gives single of fixed GPS location:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
Please be aware that both of LocationProvider.getStatus and LocationProvider.getLastKnownLocation needs to be implemented efficiently since they may be invokded with very high frequency (for eg, 4HZ).
Step 2: Create an instance of customized location provider and inject to drive-session
Following sample code assume user already obtain an instance of drive-session:
1 2 |
|
1 2 |
|