get Gsm Lac - Android Hardware

Android examples for Hardware:GSM

Description

get Gsm Lac

Demo Code


//package com.java2s;

import android.content.Context;

import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;

public class Main {
    public static int getLac(Context context) {

        int lac = 0;
        if (context != null) {
            TelephonyManager telephonyManager = (TelephonyManager) context
                    .getSystemService(Context.TELEPHONY_SERVICE);
            if (telephonyManager != null) {

                GsmCellLocation location = (GsmCellLocation) telephonyManager
                        .getCellLocation();
                if (location != null) {
                    lac = location.getLac();
                }//from w ww  . ja  v  a2  s.c om

            }

        }
        return lac;

    }
}

Related Tutorials