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


Java GsmCellLocation.getLac方法代碼示例

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


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

示例1: getIpBaseStation

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的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: getNewCellInfo

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public CellInfo getNewCellInfo() {
    try {
        TelephonyManager tm = (TelephonyManager) CellService.get().getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();

        /* Why I use this Bitmask:
         * https://stackoverflow.com/questions/9808396/android-cellid-not-available-on-all-carriers#12969638
         */
        int cellID = location.getCid();// & 0xffff;
        int lac = location.getLac();

        String networkOperator = tm.getNetworkOperator();
        int mcc = Integer.parseInt(networkOperator.substring(0, 3));
        int mnc = Integer.parseInt(networkOperator.substring(3));

        return new CellInfo(cellID, lac, mnc, mcc, tm.getNetworkType());
    } catch (Exception e) {
        return new FakeCellInfo();
    }
}
 
開發者ID:cellservice,項目名稱:cellservice,代碼行數:21,代碼來源:CellInfoObserver.java

示例3: isCellLocationEqual

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
private boolean isCellLocationEqual(CellLocation cl1, CellLocation cl2) {
    boolean result;
    if (cl1 instanceof GsmCellLocation && cl2 instanceof GsmCellLocation) {
        GsmCellLocation gsm1 = (GsmCellLocation) cl1;
        GsmCellLocation gsm2 = (GsmCellLocation) cl2;
        result = (gsm1.getCid() == gsm2.getCid()
                && gsm1.getLac() == gsm2.getLac()
                && gsm1.getPsc() == gsm2.getPsc());
        Log.d("isCellLocationEqual(): GSM equals = %s", result);
    } else if (cl1 instanceof CdmaCellLocation && cl2 instanceof CdmaCellLocation) {
        CdmaCellLocation cdma1 = (CdmaCellLocation) cl1;
        CdmaCellLocation cdma2 = (CdmaCellLocation) cl2;
        result = (cdma1.getBaseStationId() == cdma2.getBaseStationId()
                && cdma1.getNetworkId() == cdma2.getNetworkId()
                && cdma1.getSystemId() == cdma2.getSystemId());
        Log.d("isCellLocationEqual(): CDMA equal = %s", result);
    } else {
        // different types or nulls
        result = false;
        Log.d("isCellLocationEqual(): Different types or nulls");
    }
    return result;
}
 
開發者ID:zamojski,項目名稱:TowerCollector,代碼行數:24,代碼來源:MeasurementUpdater.java

示例4: ay

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
ay(CellLocation celllocation)
{
    a = 0x7fffffff;
    b = 0x7fffffff;
    c = 0x7fffffff;
    d = 0x7fffffff;
    e = 0x7fffffff;
    if (celllocation != null)
    {
        if (celllocation instanceof GsmCellLocation)
        {
            GsmCellLocation gsmcelllocation = (GsmCellLocation)celllocation;
            e = gsmcelllocation.getCid();
            d = gsmcelllocation.getLac();
        } else
        if (celllocation instanceof CdmaCellLocation)
        {
            CdmaCellLocation cdmacelllocation = (CdmaCellLocation)celllocation;
            c = cdmacelllocation.getBaseStationId();
            b = cdmacelllocation.getNetworkId();
            a = cdmacelllocation.getSystemId();
            return;
        }
    }
}
 
開發者ID:vishnudevk,項目名稱:MiBandDecompiled,代碼行數:26,代碼來源:ay.java

示例5: sendGsmBrodcat

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
private void sendGsmBrodcat(CellLocation location) {
    Log.d(TAG, "onCellLocationChanged : " + location);
        if (location instanceof GsmCellLocation) {
            String networkOperator = telephonyManager.getNetworkOperator();
            if (networkOperator != null) {
                // Mobile Country Code
                 int mcc = Integer.parseInt(networkOperator.substring(0, 3));
                 // Mobile Network Code
                int mnc = Integer.parseInt(networkOperator.substring(3));
                Log.d(TAG, String.format("networkOperator mcc=%s / mnc=%s", mcc, mnc));
            }
     
           GsmCellLocation gsmLocation = (GsmCellLocation)location;
           int cid = gsmLocation.getCid();
           int lac = gsmLocation.getLac();
            sendGsmBrodcat(cid, lac);
       }
}
 
開發者ID:gabuzomeu,項目名稱:geoPingProject,代碼行數:19,代碼來源:BackgroudLocService.java

示例6: getCellId

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
 * {link http://www.devx.com/wireless/Article/40524/0/page/2}
 */
private int[] getCellId() {
    int[] cellId = new int[0];
    CellLocation cellLoc = telephonyManager.getCellLocation();
    if (cellLoc != null && (cellLoc instanceof GsmCellLocation)) {
        GsmCellLocation gsmLoc = (GsmCellLocation) cellLoc;
        gsmLoc.getPsc();
        // gsm cell id
        int cid = gsmLoc.getCid();
        // gsm location area code
        int lac = gsmLoc.getLac();
        // On a UMTS network, returns the primary scrambling code of the
        // serving cell.
        int psc = gsmLoc.getPsc();
        Log.d(TAG, String.format("Cell Id : %s  / Lac : %s  / Psc : %s", cid, lac, psc));
        if (psc > -1) {
            cellId = new int[3];
            cellId[2] = psc;
        } else {
            cellId = new int[2];
        }
        cellId[0] = cid;
        cellId[1] = lac;
    }
    return cellId;
}
 
開發者ID:gabuzomeu,項目名稱:geoPingProject,代碼行數:29,代碼來源:GeoPingSlaveLocationService.java

示例7: getCurrentLocation

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public static void getCurrentLocation(Context context) {
    TelephonyManager mTelephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    // 返回值MCC + MNC
    String operator = mTelephonyManager.getNetworkOperator();
    int mcc = Integer.parseInt(operator.substring(0, 3));
    int mnc = Integer.parseInt(operator.substring(3));
    Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t");
    // 中國移動和中國聯通獲取LAC、CID的方式
    GsmCellLocation location = (GsmCellLocation) mTelephonyManager.getCellLocation();
    int lac = location.getLac();
    int cellId = location.getCid();



    // 中國電信獲取LAC、CID的方式
    CdmaCellLocation location1 = (CdmaCellLocation) mTelephonyManager.getCellLocation();
    lac = location1.getNetworkId();
    cellId = location1.getBaseStationId();
    cellId /= 16;

    Log.i(TAG, " MCC = " + mcc + "\t MNC = " + mnc + "\t LAC = " + lac + "\t CID = " + cellId);
    // 獲取鄰區基站信息
    List<NeighboringCellInfo> infos = mTelephonyManager.getNeighboringCellInfo();
    StringBuffer sb = new StringBuffer("總數 : " + infos.size() + "\n");
    for (NeighboringCellInfo info1 : infos) { // 根據鄰區總數進行循環
        sb.append(" LAC : " + info1.getLac()); // 取出當前鄰區的LAC
        sb.append(" CID : " + info1.getCid()); // 取出當前鄰區的CID
        sb.append(" BSSS : " + (-113 + 2 * info1.getRssi()) + "\n"); // 獲取鄰區基站信號強度
    }

    Log.i(TAG, " 獲取鄰區基站信息:" + sb.toString());
}
 
開發者ID:GOutPlay,項目名稱:LBS,代碼行數:34,代碼來源:GSMCellLocationLbs.java

示例8: getCellInfo

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public static CellInfo getCellInfo(Context context) {
      CellInfo cellInfo = new CellInfo();

      TelephonyManager manager = (TelephonyManager)
              context.getSystemService(Context.TELEPHONY_SERVICE);

      String netOperator = manager.getNetworkOperator();

      // Fix crash when not connected to network (airplane mode, underground,
      // etc)
      if (netOperator == null || netOperator.length() < 3) {
          return cellInfo;
      }

/*
 * FIXME: Actually check for mobile network status == connected before
 * doing this stuff.
 */

      if (Phone.getType(context).equals(PHONE_TYPE_CDMA)) {
          CdmaCellLocation cdmaLocation = (CdmaCellLocation) manager.getCellLocation();

          cellInfo.cid = cdmaLocation.getBaseStationId();
          cellInfo.lac = cdmaLocation.getNetworkId();
          cellInfo.mnc = cdmaLocation.getSystemId();
          cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
          cellInfo.radioType = Network.getMobileNetworkType(context);
      } else if (Phone.getType(context).equals(PHONE_TYPE_GSM)) {
          GsmCellLocation gsmLocation = (GsmCellLocation) manager.getCellLocation();

          cellInfo.mcc = Integer.parseInt(netOperator.substring(0, 3));
          cellInfo.mnc = Integer.parseInt(netOperator.substring(3));
          cellInfo.lac = gsmLocation.getLac();
          cellInfo.cid = gsmLocation.getCid();
          cellInfo.radioType = Network.getMobileNetworkType(context);
      }

      return cellInfo;
  }
 
開發者ID:greenhub-project,項目名稱:batteryhub,代碼行數:40,代碼來源:Gsm.java

示例9: getCellLac

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public static int getCellLac(Context context) {

		TelephonyManager telephonyManager = (TelephonyManager) context
				.getSystemService(Context.TELEPHONY_SERVICE);
		GsmCellLocation cellLocation = (GsmCellLocation) telephonyManager
				.getCellLocation();
		int lac = cellLocation.getLac();
		return lac;
	}
 
開發者ID:GDGMiageGiLab,項目名稱:CAN-2015,代碼行數:10,代碼來源:Utils.java

示例10: getNetworkState

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
 * Retrieves network info data. *
 *
 * @return Current network info data.
 */
public static NetworkState getNetworkState(Context context) {
    NetworkState callInfoData = null;
    try {
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
        GsmCellLocation location = (GsmCellLocation) telephonyManager.getCellLocation();
        String mcc = "0";
        String mnc = "0";
        String networkOperator = telephonyManager.getNetworkOperator();
        if (networkOperator != null && networkOperator.length() > 0) {
            mcc = telephonyManager.getNetworkOperator().substring(0, 3);
            mnc = telephonyManager.getNetworkOperator().substring(3);
        }

        int[] neighborCellId;
        int[] neighborCellRssi;

        List<NeighboringCellInfo> neighboringList = telephonyManager.getNeighboringCellInfo();
        if (neighboringList != null && !neighboringList.isEmpty()) {
            neighborCellId = new int[neighboringList.size()];
            neighborCellRssi = new int[neighboringList.size()];
            for (int i = 0; i < neighboringList.size(); i++) {
                neighborCellRssi[i] = neighboringList.get(i).getRssi();
                neighborCellId[i] = neighboringList.get(i).getCid();
            }
        } else {
            neighborCellId = new int[] { -1 };
            neighborCellRssi = new int[] { -1 };
        }

        callInfoData = new NetworkState(System.currentTimeMillis(), (location != null) ? location.getCid() : 0, /* rssi, dbm, asu, */0, 0, 0,
                mcc, mnc, (location != null) ? location.getLac() : 0, NetworkUtils.isInRoaming(context),
                NetworkUtils.getDataConnectionState(context), NetworkUtils.getSimState(context), NetworkUtils.getNetworkType(context),
                NetworkUtils.isWiFiEnabled(context), neighborCellId, neighborCellRssi);
    } catch (final Exception e) {
        Logger.logApplicationException(e, NetworkUtils.class.getSimpleName() + ".getNetworkInfoData(): Failed.");
        e.printStackTrace();
    }
    return callInfoData;
}
 
開發者ID:ashank,項目名稱:Office-365-SDK-for-Android,代碼行數:45,代碼來源:NetworkUtils.java

示例11: x

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
protected static String x(Context paramContext)
{
  TelephonyManager localTelephonyManager = (TelephonyManager)paramContext.getSystemService("phone");
  if (localTelephonyManager.getPhoneType() == 1)
  {
    GsmCellLocation localGsmCellLocation = (GsmCellLocation)localTelephonyManager.getCellLocation();
    if (localGsmCellLocation != null)
      return localGsmCellLocation.getLac() + "";
  }
  return "-1";
}
 
開發者ID:zhangjianying,項目名稱:12306-android-Decompile,代碼行數:12,代碼來源:l.java

示例12: getJsonCellPos

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
private String getJsonCellPos() throws JSONException {
	TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
	GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
	if (location == null) {
		return null;
	}
	int cid = location.getCid();
	int lac = location.getLac();
	String netOperator = tm.getNetworkOperator();
	int mcc = Integer.valueOf(netOperator.substring(0, 3));
	int mnc = Integer.valueOf(netOperator.substring(3, 5));
	System.out.println("cid" + cid + ",lac" + lac + ",mcc" + mcc + "" + ",mnc" + mnc);
	JSONObject jsonCellPos = new JSONObject();
	jsonCellPos.put("version", "1.1.0");
	jsonCellPos.put("host", "maps.google.com");

	JSONArray array = new JSONArray();
	JSONObject json1 = new JSONObject();
	json1.put("location_area_code", "" + lac + "");
	json1.put("mobile_country_code", "" + mcc + "");
	json1.put("mobile_network_code", "" + mnc + "");
	json1.put("age", 0);
	json1.put("cell_id", "" + cid + "");
	array.put(json1);
	jsonCellPos.put("cell_towers", array);
	return jsonCellPos.toString();
}
 
開發者ID:andieguo,項目名稱:nearbydemo,代碼行數:28,代碼來源:TelephonyActivity.java

示例13: getJsonCellPos1

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
public String getJsonCellPos1() {
	TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
	GsmCellLocation location = (GsmCellLocation) tm.getCellLocation();
	if (location == null) {
		return null;
	}
	int cid = location.getCid();
	int lac = location.getLac();
	String netOperator = tm.getNetworkOperator();
	int mcc = Integer.valueOf(netOperator.substring(0, 3));
	int mnc = Integer.valueOf(netOperator.substring(3, 5));
	System.out.println("cid" + cid + ",lac" + lac + ",mcc" + mcc + "" + ",mnc" + mnc);
	holder = new JSONObject();
	JSONArray array = new JSONArray();
	JSONObject data = new JSONObject();
	try {
		holder.put("version", "1.1.0");
		holder.put("host", "maps.google.com");
		holder.put("address_language", "zh_CN");
		holder.put("request_address", true);
		holder.put("radio_type", "gsm");
		holder.put("carrier", "HTC");
		data.put("cell_id", cid);
		data.put("location_area_code", lac);
		data.put("mobile_countyr_code", mcc);
		data.put("mobile_network_code", mnc);
		array.put(data);
		holder.put("cell_towers", array);
		Log.i(TAG, "JSON��Ϣ��" + holder.toString());
		return holder.toString();
	} catch (JSONException e) {
		e.printStackTrace();
	}
	return null;

}
 
開發者ID:andieguo,項目名稱:nearbydemo,代碼行數:37,代碼來源:TelephonyActivity.java

示例14: update

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
 * Adds or updates a cell tower.
 * <p>
 * If the cell tower is already in the list, its data is updated; if not, a
 * new entry is created.
 * <p>
 * This method will set the cell's identity data. After this call,
 * {@link #isServing()} will return {@code true} for this cell.
 * @param networkOperator The network operator, as returned by {@link android.telephony.TelephonyManager#getNetworkOperator()}.
 * @param location The {@link android.telephony.GsmCellLocation}, as returned by {@link android.telephony.TelephonyManager#getCellLocation()}.
 * @return The new or updated entry.
 */
public CellTowerLte update(String networkOperator, GsmCellLocation location) {
	int mcc = CellTower.UNKNOWN;
	int mnc = CellTower.UNKNOWN;
	if (networkOperator.length() > 3) {
		mcc = Integer.parseInt(networkOperator.substring(0, 3));
		mnc = Integer.parseInt(networkOperator.substring(3));
	}
	CellTowerLte result = null;
	CellTowerLte cand = this.get(mcc, mnc, location.getLac(), location.getCid());
	if ((cand != null) && CellTower.matches(location.getPsc(), cand.getPci()))
		result = cand;
	if (result == null) {
		cand = this.get(location.getPsc());
		if ((cand != null)
				&& CellTower.matches(mcc, cand.getMcc())
				&& CellTower.matches(mnc, cand.getMnc())
				&& CellTower.matches(location.getLac(), cand.getTac())
				&& CellTower.matches(location.getCid(), cand.getCi()))
			result = cand;
	}
	if (result == null)
		result = new CellTowerLte(mcc, mnc, location.getLac(), location.getCid(), location.getPsc());
	if (result.getMcc() == CellTower.UNKNOWN)
		result.setMcc(mcc);
	if (result.getMnc() == CellTower.UNKNOWN)
		result.setMnc(mnc);
	if (result.getTac() == CellTower.UNKNOWN)
		result.setTac(location.getLac());
	if (result.getCi() == CellTower.UNKNOWN)
		result.setCi(location.getCid());
	if (result.getPci() == CellTower.UNKNOWN)
		result.setPci(location.getPsc());
	this.put(result.getText(), result);
	this.put(result.getAltText(), result);
	result.setCellLocation(true);
	Log.d(this.getClass().getSimpleName(), String.format("Added GsmCellLocation for %s, %d G", result.getText(), result.getGeneration()));
	return result;
}
 
開發者ID:mvglasow,項目名稱:satstat,代碼行數:51,代碼來源:CellTowerListLte.java

示例15: update

import android.telephony.gsm.GsmCellLocation; //導入方法依賴的package包/類
/**
 * Adds or updates a cell tower.
 * <p>
 * If the cell tower is already in the list, its data is updated; if not, a
 * new entry is created.
 * <p>
 * This method will set the cell's identity data. After this call,
 * {@link #isServing()} will return {@code true} for this cell. 
 * @param networkOperator The network operator, as returned by {@link android.telephony.TelephonyManager#getNetworkOperator()}.
 * @param location The {@link android.telephony.GsmCellLocation}, as returned by {@link android.telephony.TelephonyManager#getCellLocation()}.
 * @return The new or updated entry.
 */
public CellTowerGsm update(String networkOperator, GsmCellLocation location) {
	int mcc = CellTower.UNKNOWN;
	int mnc = CellTower.UNKNOWN;
	if (networkOperator.length() > 3) {
		mcc = Integer.parseInt(networkOperator.substring(0, 3));
		mnc = Integer.parseInt(networkOperator.substring(3));
	}
	CellTowerGsm result = null;
	CellTowerGsm cand = this.get(mcc, mnc, location.getLac(), location.getCid());
	if ((cand != null) && CellTower.matches(location.getPsc(), cand.getPsc()))
		result = cand;
	if (result == null) {
		cand = this.get(location.getPsc());
		if ((cand != null)
				&& CellTower.matches(mcc, cand.getMcc())
				&& CellTower.matches(mnc, cand.getMnc())
				&& CellTower.matches(location.getLac(), cand.getLac())
				&& CellTower.matches(location.getCid(), cand.getCid()))
			result = cand;
	}
	if (result == null)
		result = new CellTowerGsm(mcc, mnc, location.getLac(), location.getCid(), location.getPsc());
	if (result.getMcc() == CellTower.UNKNOWN)
		result.setMcc(mcc);
	if (result.getMnc() == CellTower.UNKNOWN)
		result.setMnc(mnc);
	if (result.getLac() == CellTower.UNKNOWN)
		result.setLac(location.getLac());
	if (result.getCid() == CellTower.UNKNOWN)
		result.setCid(location.getCid());
	if (result.getPsc() == CellTower.UNKNOWN)
		result.setPsc(location.getPsc());
	this.put(result.getText(), result);
	this.put(result.getAltText(), result);
	if ((result.getText() == null) && (result.getAltText() == null))
		Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from GsmCellLocation", result.getGeneration()));
	result.setCellLocation(true);
	return result;
}
 
開發者ID:mvglasow,項目名稱:satstat,代碼行數:52,代碼來源:CellTowerListGsm.java


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