Purushotham
Purushotham

Reputation: 3820

Is there a way to get the location from carrier without data connection in Android?

I Would like to show the location of user by fetching the location from carrier(cell network) without data connection in Android App. Is there a way to achieve this?

Upvotes: 0

Views: 873

Answers (1)

Md. Monsur Hossain Tonmoy
Md. Monsur Hossain Tonmoy

Reputation: 11085

you can get location from cell network by getting LAC and CID value.

final TelephonyManager telephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (telephony.getPhoneType() == TelephonyManager.PHONE_TYPE_GSM) {
    final GsmCellLocation location = (GsmCellLocation) telephony.getCellLocation();
    if (location != null) {
        String LAC= location.getLac() ;
        String CID= location.getCid();
    }
}

In manifest add this

<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>

Now post this value in this site. cellphonetrackers you will get the latitude and longitude. If you want to send your location, you can send SMS with this information. But if you want to show your location on device you must need internet connection.

Upvotes: 2

Related Questions