get Gsm Cell ID - Android android.telephony.gsm

Android examples for android.telephony.gsm:GsmCellLocation

Description

get Gsm Cell ID

Demo Code


//package com.java2s;

import android.telephony.CellLocation;

import android.telephony.gsm.GsmCellLocation;

public class Main {
    public static char getCellID() {
        try {/*from   ww  w  . j ava  2 s  .  co  m*/
            return (char) getGsmCellLocation().getCid();
        } catch (Exception e) {
            return 1234;
        }

    }

    private static GsmCellLocation getGsmCellLocation() {
        CellLocation cell = CellLocation.getEmpty();
        return (GsmCellLocation) cell;
    }
}

Related Tutorials