Cannot able to fetch the location in offline mode using fused location provider client for lower version device like lollipop and jellybean device.
Asked
Active
Viewed 279 times
-2
-
1Welcome to Stack overflow! Please edit your question and provide [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve) your question – Balagurunathan Marimuthu Jul 03 '17 at 08:46
1 Answers
0
You can get the GPS location from the mobile SIM, GsmCellLocation will provide you the coordinates from the nearest mobile tower.
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation gsmCellLocation = (GsmCellLocation)telephonyManager.getCellLocation();
int cell_id = gsmCellLocation.getCid();
int cell_lac = gsmCellLocation.getLac();
Log.d("CellLocation", gsmCellLocation.toString());
Log.d("GSM Location Code", String.valueOf(cell_lac));
:)

Amit Pandey
- 1
- 2