get Gsm Cid - Android Hardware

Android examples for Hardware:GSM

Description

get Gsm Cid

Demo Code


//package com.java2s;

import android.content.Context;

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

public class Main {
    public static int gegtCid(Context context) {
        int cid = 0;
        if (context != null) {
            TelephonyManager telephonyManager = (TelephonyManager) context
                    .getSystemService(Context.TELEPHONY_SERVICE);
            if (telephonyManager != null) {

                GsmCellLocation location = (GsmCellLocation) telephonyManager
                        .getCellLocation();
                if (location != null) {
                    cid = location.getCid();
                }//  w  ww  .  j a va  2s . com

            }

        }
        return cid;

    }
}

Related Tutorials