當前位置: 首頁>>代碼示例>>Java>>正文


Java TelephonyManager.getCellLocation方法代碼示例

本文整理匯總了Java中android.telephony.TelephonyManager.getCellLocation方法的典型用法代碼示例。如果您正苦於以下問題:Java TelephonyManager.getCellLocation方法的具體用法?Java TelephonyManager.getCellLocation怎麽用?Java TelephonyManager.getCellLocation使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.telephony.TelephonyManager的用法示例。


在下文中一共展示了TelephonyManager.getCellLocation方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getIpBaseStation

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static String getIpBaseStation() {
    TelephonyManager telMgr = (TelephonyManager) FDApplication
            .getInstance().getSystemService(Context.TELEPHONY_SERVICE);
    int cid = 0;
    int lac = 0;
    try {
        if (telMgr != null) {
            GsmCellLocation gc = (GsmCellLocation) telMgr.getCellLocation();
            if (null == gc) {
                return "0_0";
            }
            cid = gc.getCid();
            lac = gc.getLac();
        }
    } catch (Exception e) {
        if (telMgr != null) {
            CdmaCellLocation location = (CdmaCellLocation) telMgr
                    .getCellLocation();
            if (null == location) {
                return "0_0";
            }
            lac = location.getNetworkId();
            cid = location.getBaseStationId();
            cid /= 16;
        }
    }
    return lac + "_" + cid;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:29,代碼來源:StrUtils.java

示例2: getTowerValues

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
private int[] getTowerValues() {
	// Find new values
	TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
	// Find the location
	if (tm == null) {
		popupMsg("Could not get TelephonyManager");
		return null;
	}
	int phoneType = tm.getPhoneType();
	if (phoneType != TelephonyManager.PHONE_TYPE_CDMA) {
		popupMsg("Only CDMA is supported");
		return null;
	}
	CellLocation cl = tm.getCellLocation();
	if (cl == null) {
		popupMsg("Could not get Cell Location");
		return null;
	}
	if (!(cl instanceof CdmaCellLocation)) {
		popupMsg("Cell Location is is not a CdmaCellLocation class");
		return null;
	}
	CdmaCellLocation cdmacl = (CdmaCellLocation) cl;
	int lat = NetworkActivity.locToGoogle(cdmacl.getBaseStationLatitude());
	int lon = NetworkActivity.locToGoogle(cdmacl.getBaseStationLongitude());
	int nid = cdmacl.getNetworkId();
	int sid = cdmacl.getSystemId();
	int bid = cdmacl.getBaseStationId();
	Log.d(TAG, "  New values: " + " lat=" + lat + " lon=" + lon + " nid="
			+ nid + " sid=" + sid + " bid=" + bid);
	return new int[] { lat, lon, nid, sid, bid };
}
 
開發者ID:KennethEvans,項目名稱:Misc,代碼行數:33,代碼來源:MapLocationActivity.java

示例3: getGSMInfo

import android.telephony.TelephonyManager; //導入方法依賴的package包/類
public static GSMInfo getGSMInfo(Context context) {
    try {
        GSMInfo info = new GSMInfo();
        TelephonyManager manager = (TelephonyManager) context.getSystemService("phone");
        if (manager != null) {
            CellLocation cellLocation = manager.getCellLocation();
            int lac = 0;
            int cellid = 0;
            if (cellLocation != null) {
                if (cellLocation instanceof GsmCellLocation) {
                    lac = ((GsmCellLocation) cellLocation).getLac();
                    cellid = ((GsmCellLocation) cellLocation).getCid();
                } else if (cellLocation instanceof CdmaCellLocation) {
                    cellid = ((CdmaCellLocation) cellLocation).getNetworkId();
                    lac = ((CdmaCellLocation) cellLocation).getBaseStationId();
                }
            }
            info.lac = lac;
            info.cid = cellid;
        }
        AMapLocation location = AMapLocationTool.getInstance().location();
        if (location != null) {
            info.latitude = location.getLatitude();
            info.longitude = location.getLongitude();
            return info;
        }
        info.latitude = Double.parseDouble(PreferencesManager.getInstance().getLocationLongitude());
        info.longitude = Double.parseDouble(PreferencesManager.getInstance().getLocationLatitude());
        return info;
    } catch (Exception e) {
        LogInfo.log("ZSM++ ==== GSM exception e == " + e.getMessage());
        e.printStackTrace();
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:36,代碼來源:LetvUtils.java


注:本文中的android.telephony.TelephonyManager.getCellLocation方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。