本文整理汇总了Java中android.telephony.CellIdentityGsm.getLac方法的典型用法代码示例。如果您正苦于以下问题:Java CellIdentityGsm.getLac方法的具体用法?Java CellIdentityGsm.getLac怎么用?Java CellIdentityGsm.getLac使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.telephony.CellIdentityGsm
的用法示例。
在下文中一共展示了CellIdentityGsm.getLac方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCellularInfo
import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
public String getCellularInfo(TelephonyManager telephonyManager)
{
String cellularInfo = "";
String log = "";
if(telephonyManager.getAllCellInfo()==null) {
Log.v(TAG, "getAllCellInfo returned null");
}
else {
for (final CellInfo info : telephonyManager.getAllCellInfo()) {
if (info instanceof CellInfoGsm) {
log += "[email protected]";
CellIdentityGsm gsm_cell = ((CellInfoGsm) info).getCellIdentity();
log += gsm_cell.getCid() + "#" + gsm_cell.getLac() + "#" + gsm_cell.getMcc() + "#" + gsm_cell.getMnc() + "_";
final CellSignalStrengthGsm gsm = ((CellInfoGsm) info).getCellSignalStrength();
log += gsm.getDbm() + "#" + gsm.getLevel()+"#"+gsm.getAsuLevel()+":";
} else if (info instanceof CellInfoCdma) {
log += "[email protected]";
CellIdentityCdma cdma_cell = ((CellInfoCdma) info).getCellIdentity();
log += cdma_cell.getBasestationId() + "#" + cdma_cell.getNetworkId() + "#" + cdma_cell.getSystemId() + "#" + cdma_cell.getSystemId() + "_";
final CellSignalStrengthCdma cdma = ((CellInfoCdma) info).getCellSignalStrength();
log += cdma.getDbm() + "#" + cdma.getLevel()+"#"+cdma.getAsuLevel()+":";
} else if (info instanceof CellInfoLte) {
log += "[email protected]";
CellIdentityLte lte_cell = ((CellInfoLte) info).getCellIdentity();
log += lte_cell.getCi() + "#" + lte_cell.getPci() + "#" + lte_cell.getMcc() + "#" + lte_cell.getMnc() + "_";
final CellSignalStrengthLte lte = ((CellInfoLte) info).getCellSignalStrength();
log += lte.getDbm() + "#" + lte.getLevel()+"#"+lte.getAsuLevel()+":";
} else if (info instanceof CellInfoWcdma) {
log += "[email protected]";
CellIdentityWcdma wcdma_cell = ((CellInfoWcdma) info).getCellIdentity();
log += wcdma_cell.getCid() + "#" + wcdma_cell.getLac() + "#" + wcdma_cell.getMcc() + "#" + wcdma_cell.getMnc() + "_";
final CellSignalStrengthWcdma wcdma = ((CellInfoWcdma) info).getCellSignalStrength();
log += wcdma.getDbm() + "#" + wcdma.getLevel()+"#"+wcdma.getAsuLevel()+":";
} else {
Log.v(TAG, "Unknown Network Type");
}
}
}
cellularInfo = log;
return cellularInfo;
}
示例2: fill
import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
public static void fill(TheDictionary map, CellIdentityGsm value) throws Exception {
if (value != null) {
map.put("type", "2");
int i;
i = value.getMcc();
if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mcc", i);
i = value.getMnc();
if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mnc", i);
i = value.getLac();
if (i != Integer.MAX_VALUE && i > 0) map.put("lac", i);
i = value.getCid();
if (i != Integer.MAX_VALUE && i > 0) map.put("cid", i);
//map.put("psc", value.getPsc()); // depricated
}
}
示例3: fill
import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
public static void fill(TheDictionary map, CellIdentityGsm value) throws Exception {
if (value != null) {
map.put("type", "2");
int i;
i = value.getMcc(); if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mcc", i);
i = value.getMnc(); if (i != Integer.MAX_VALUE && i > 0 && i < 1000) map.put("mnc", i);
i = value.getLac(); if (i != Integer.MAX_VALUE && i > 0) map.put("lac", i);
i = value.getCid(); if (i != Integer.MAX_VALUE && i > 0) map.put("cid", i);
//map.put("psc", value.getPsc()); // depricated
}
}
示例4: startScan
import android.telephony.CellIdentityGsm; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void startScan() {
logMessage("starting tower scan... ");
Scan scan = new Scan();
// TODO: Get location from user?
scan.setLocation(lastScanName);
// TODO: use actual GPS Coordinates
scan.setLatitude(lastScanLat);
scan.setLongitude(lastScanLon);
long scan_id = db.createScan(scan);
List<CellInfo> cellInfos = (List<CellInfo>) this.telephonyManager
.getAllCellInfo();
// TODO: better error handling of null cellinfos
if (cellInfos != null) {
for (CellInfo cellInfo : cellInfos) {
if (cellInfo instanceof CellInfoGsm) {
CellInfoGsm cellInfoGsm = (CellInfoGsm) cellInfo;
CellIdentityGsm cellIdentity = cellInfoGsm
.getCellIdentity();
CellSignalStrengthGsm cellSignalStrengthGsm = cellInfoGsm
.getCellSignalStrength();
int dbmLevel = cellSignalStrengthGsm.getDbm();
com.spideyapp.sqlite.model.CellInfo cell = new com.spideyapp.sqlite.model.CellInfo(
cellIdentity.getCid(), cellIdentity.getLac(),
cellIdentity.getMcc(), cellIdentity.getMnc(),dbmLevel);
db.createCell(cell, scan_id);
shareCellInfo (cell);
}
}
}
}
示例5: update
import android.telephony.CellIdentityGsm; //导入方法依赖的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, its signal strength and
* whether it is the currently serving cell. If the API level is 18 or
* higher, it will also set the generation.
* @return The new or updated entry.
*/
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public CellTowerGsm update(CellInfoGsm cell) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return null;
CellIdentityGsm cid = cell.getCellIdentity();
CellTowerGsm result = null;
CellTowerGsm cand = this.get(cid.getMcc(), cid.getMnc(), cid.getLac(), cid.getCid());
if ((cand != null) && CellTower.matches(cid.getPsc(), cand.getPsc()))
result = cand;
if (result == null) {
cand = this.get(cid.getPsc());
if ((cand != null)
&& ((cid.getMcc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMcc(), cand.getMcc()))
&& ((cid.getMnc() == Integer.MAX_VALUE) || CellTower.matches(cid.getMnc(), cand.getMnc()))
&& ((cid.getLac() == Integer.MAX_VALUE) || CellTower.matches(cid.getLac(), cand.getLac()))
&& ((cid.getCid() == Integer.MAX_VALUE) ||CellTower.matches(cid.getCid(), cand.getCid())))
result = cand;
}
if (result == null)
result = new CellTowerGsm(cid.getMcc(), cid.getMnc(), cid.getLac(), cid.getCid(), cid.getPsc());
if (result.getMcc() == CellTower.UNKNOWN)
result.setMcc(cid.getMcc());
if (result.getMnc() == CellTower.UNKNOWN)
result.setMnc(cid.getMnc());
if (result.getLac() == CellTower.UNKNOWN)
result.setLac(cid.getLac());
if (result.getCid() == CellTower.UNKNOWN)
result.setCid(cid.getCid());
if (result.getPsc() == CellTower.UNKNOWN)
result.setPsc(cid.getPsc());
this.put(result.getText(), result);
this.put(result.getAltText(), result);
result.setCellInfo(true);
result.setDbm(cell.getCellSignalStrength().getDbm());
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2)
result.setGeneration(2);
result.setServing(cell.isRegistered());
if ((result.getText() == null) && (result.getAltText() == null))
Log.d(this.getClass().getSimpleName(), String.format("Added %d G cell with no data from CellInfoGsm", result.getGeneration()));
return result;
}