㈠ java如何實現電子地圖的定位
CellInfoManager
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import android.content.Context;
import android.telephony.CellLocation;
import android.telephony.NeighboringCellInfo;
import android.telephony.PhoneStateListener;
import android.telephony.TelephonyManager;
import android.telephony.gsm.GsmCellLocation;
import android.util.Log;
public class CellInfoManager {
private int asu;
private int bid;
private int cid;
private boolean isCdma;
private boolean isGsm;
private int lac;
private int lat;
private final PhoneStateListener listener;
private int lng;
private int mcc;
private int mnc;
private int nid;
private int sid;
private TelephonyManager tel;
private boolean valid;
private Context context;
public CellInfoManager(Context paramContext) {
this.listener = new CellInfoListener(this);
tel = (TelephonyManager) paramContext.getSystemService(Context.TELEPHONY_SERVICE);
this.tel.listen(this.listener, PhoneStateListener.LISTEN_CELL_LOCATION | PhoneStateListener.LISTEN_SIGNAL_STRENGTH);
context = paramContext;
}
public static int dBm(int i) {
int j;
if (i >= 0 && i <= 31)
j = i * 2 + -113;
else
j = 0;
return j;
}
public int asu() {
return this.asu;
}
public int bid() {
if (!this.valid)
update();
return this.bid;
}
public JSONObject cdmaInfo() {
if (!isCdma()) {
return null;
}
JSONObject jsonObject = new JSONObject();
try {
jsonObject.put("bid", bid());
jsonObject.put("sid", sid());
jsonObject.put("nid", nid());
jsonObject.put("lat", lat());
jsonObject.put("lng", lng());
} catch (JSONException ex) {
jsonObject = null;
Log.e("CellInfoManager", ex.getMessage());
}
return jsonObject;
}
public JSONArray cellTowers() {
JSONArray jsonarray = new JSONArray();
int lat;
int mcc;
int mnc;
int aryCell[] = mpCells();
lat = lac();
mcc = mcc();
mnc = mnc();
if (aryCell == null || aryCell.length < 2) {
aryCell = new int[2];
aryCell[0] = cid;
aryCell[1] = -60;
}
for (int i = 0; i < aryCell.length; i += 2) {
try {
int j2 = dBm(i + 1);
JSONObject jsonobject = new JSONObject();
jsonobject.put("cell_id", aryCell[i]);
jsonobject.put("location_area_code", lat);
jsonobject.put("mobile_country_code", mcc);
jsonobject.put("mobile_network_code", mnc);
jsonobject.put("signal_strength", j2);
jsonobject.put("age", 0);
jsonarray.put(jsonobject);
} catch (Exception ex) {
ex.printStackTrace();
Log.e("CellInfoManager", ex.getMessage());
}
}
if (isCdma())
jsonarray = new JSONArray();
return jsonarray;
}
public int cid() {
if (!this.valid)
update();
return this.cid;
}
public int[] mpCells() {
int[] aryCells;
if (cid() == 0) {
aryCells = new int[0];
return aryCells;
}
List<NeighboringCellInfo> lsCellInfo = this.tel.getNeighboringCellInfo();
if (lsCellInfo == null || lsCellInfo.size() == 0) {
aryCells = new int[1];
int i = cid();
aryCells[0] = i;
檢舉補充回答:
return aryCells;
}
int[] arrayOfInt1 = new int[lsCellInfo.size() * 2 + 2];
int j = 0 + 1;
int k = cid();
arrayOfInt1[0] = k;
int m = j + 1;
int n = asu();
arrayOfInt1[j] = n;
Iterator<NeighboringCellInfo> iter = lsCellInfo.iterator();
while (true) {
if (!iter.hasNext()) {
break;
}
NeighboringCellInfo localNeighboringCellInfo = (NeighboringCellInfo) iter.next();
int i2 = localNeighboringCellInfo.getCid();
if ((i2 <= 0) || (i2 == 65535))
continue;
int i3 = m + 1;
arrayOfInt1[m] = i2;
m = i3 + 1;
int i4 = localNeighboringCellInfo.getRssi();
arrayOfInt1[i3] = i4;
}
int[] arrayOfInt2 = new int[m];
System.array(arrayOfInt1, 0, arrayOfInt2, 0, m);
aryCells = arrayOfInt2;
return aryCells;
}
public JSONObject gsmInfo() {
if (!isGsm()) {
return null;
}
JSONObject localObject = null;
while (true) {
try {
檢舉補充回答: JSONObject localJSONObject1 = new JSONObject();
String str1 = this.tel.getNetworkOperatorName();
localJSONObject1.put("operator", str1);
String str2 = this.tel.getNetworkOperator();
if ((str2.length() == 5) || (str2.length() == 6)) {
String str3 = str2.substring(0, 3);
String str4 = str2.substring(3, str2.length());
localJSONObject1.put("mcc", str3);
localJSONObject1.put("mnc", str4);
}
localJSONObject1.put("lac", lac());
int[] arrayOfInt = mpCells();
JSONArray localJSONArray1 = new JSONArray();
int k = 0;
int m = arrayOfInt.length / 2;
while (true) {
if (k >= m) {
localJSONObject1.put("cells", localJSONArray1);
localObject = localJSONObject1;
break;
}
int n = k * 2;
int i1 = arrayOfInt[n];
int i2 = k * 2 + 1;
int i3 = arrayOfInt[i2];
JSONObject localJSONObject7 = new JSONObject();
localJSONObject7.put("cid", i1);
localJSONObject7.put("asu", i3);
localJSONArray1.put(localJSONObject7);
k += 1;
}
} catch (JSONException localJSONException) {
localObject = null;
}
}
}
public boolean isCdma() {
if (!this.valid)
update();
㈡ Java如何定位佔用CPU比較高的問題
一、確定消耗CPU的Java進程
備註:
1、jstack 輸出的堆棧信息,線程id對應的16進制為小寫,查找時要統一按照小寫方式查找
2、jstack輸出為當前瞬間的堆棧信息,如果遇到間斷性出現CPU高的問題時,需要多輸出幾次
從上面方式定位到代碼Test.main(Test.java:4)處導致了CPU偏高的問題,那我們查看下代碼具體如何實現的?
代碼實現:
public class Test {
public static void main(String[] args) {
while(true) {
}
}
}
從代碼層面看該處實現了一個死循環,所以導致了線程佔用CPU偏高的問題。
㈢ java窗口編程中有什麼 能精確定位的方法
先設置不使用布局管理器:setLayout(null)。 然後所有控制項用setBounds(left, top, width, height)設置絕對定位(left、top)和尺寸(width、height)。 public static void main(String[] args) { JFrame f = new JFrame(); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container c = f.getContentPane(); c.setLayout(null); JButton b = new JButton("button"); b.setBounds(100, 50, 80, 40); c.add(b); f.setSize(400, 300); f.setVisible(true); }
㈣ 求java圖形界面中的組件的絕對定位方法
java圖形界面的組件可以使用絕對定位,設置x、y軸的屬性,示例如下:
public void setBounds(int x,
int y,
int width,
int height)移動組件並調整其大小。由 x 和 y 指定左上角的新位置,由 width 和 height 指定新的大小。
參數:
x - 組件的新 x 坐標
y - 組件的新 y 坐標
width - 組件的新 width
height - 組件的新 height
㈤ java中如何自動定位
自動定位需要特定的api,比如網路等。
在需要的地方調用第三方提供的api調用定位相關代碼就好。
㈥ 如何定位某個java類在哪個jar文件
java查找類在哪個jar裡面封裝的方式如下:
如果用eclipse選中類名,然後ctrl shift T,就可看到包含比類的包了,如下圖:
㈦ 如何給自己定位java學習基礎
如需學習Java,推薦選擇【達內教育】,定位學習Java的基礎可以從以下幾個方面入手:
1、心態問題。其實Java並沒有想像中的那麼難,想要入這個行業,最重要就是做好一個心理准備,如果想走遠點,就得不間斷地去學習,去汲取知識,永遠保持一個空杯心態。
2、具備一定的思考能力和解決問題的能力。在編程的過程中,會遇到許許多多的問題,要具備一定思考能力。
3、學習路線而言,從SE入門是最合適不過,期間可以做點小東西,譬如桌面的酒店管理系統。然後是javaweb部分,先從servlet入手,做一個小的網站,可以是投票系統之類,然後是框架層面,現在主流的是SSM。感興趣的話點擊此處,免費學習一下
想了解更多有關Java的相關信息,推薦咨詢【達內教育】。秉承「名師出高徒、高徒拿高薪」的教學理念,是達內公司確保教學質量的重要環節。作為美國上市職業教育公司,誠信經營,拒絕虛假宣傳是該機構集團的經營理念。該機構在學員報名之前完全公開所有授課講師的授課安排及背景資料,並與學員簽訂《指定授課講師承諾書》,確保學員利益。達內IT培訓機構,試聽名額限時搶購。
㈧ java的定位
java是目前主流的面向對象程序設計語言,沒有之一,java無疑是目前應用最廣泛的面向對象程序設計語言,C++由於不是純的面向對象設計語言,而且有較多不便的編程限制,應用受到局限,java幾乎能滿足所有bs、cs的開發需要,目前仍然有著旺盛的生命力