I want to get the value of Longitude and Latitude of my current locatoin when offline and save the current location to its database. Is it possible to get the longitude and latitude of the device when mobile data and wifi are off but the GPS is ON?
相关问题
- How can I create this custom Bottom Navigation on
- Bottom Navigation View gets Shrink Down
- How to make that the snackbar action button be sho
- Listening to outgoing sms not working android
- How to create Circular view on android wear?
相关文章
- android开发 怎么把图片放入drawable的文件夹下
- android上如何获取/storage/emulated/下的文件列表
- androidStudio有个箭头不认识
- SQLite不能创建表
- Windows - Android SDK manager not listing any plat
- Animate Recycler View grid when number of columns
- Why is the app closing suddenly without showing an
- Android OverlayItem.setMarker(): Change the marker
Just use this code. Make sure the user hasn't selected wifi only or network only option in his location setings. it has to be high accuracy or GPS only. This piece of code will work.
The parameters of requestLocationUpdates methods are as follows:
provider: the name of the provider with which we would like to register. minTime: minimum time interval between location updates (in milliseconds). minDistance: minimum distance between location updates (in meters). listener: a LocationListener whose onLocationChanged(Location) method will be called for each location update.
Permissions:
Add above permissions to manifest file for the version lower than lollipop and for marshmallow and higher version use runtime permission.