本文介紹了將網(wǎng)絡(luò)位置保存為 .txt 文件(不使用 GPS)的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
我是安卓編程的初學(xué)者.我的研究生項(xiàng)目是關(guān)于跟蹤移動(dòng)設(shè)備的,我需要將位置(不使用 GPS)保存為文本文件的代碼.有人建議我這樣做的代碼.這對我有很大的幫助.
I am a beginner in android programming. My Graduate project is about tracking a mobile device and i need the code to save the location( Without using GPS) as a text file. Someone suggest me the codes for doing that. It will be a great help for me.
推薦答案
試試這個(gè).
locationManagerNetwork = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
Location location2 = locationManagerNetwork
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location2 != null) {
String message = String
.format("Yout location :
Longitude: %1$s
Latitude: %2$s",
location2.getLongitude(), location2.getLatitude());
Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG)
.show();
//use here file writer if you want to write the coordinates in a text file
}
<小時(shí)>
用于寫入 sd 卡
for writing sd card
File sdcard = Environment.getExternalStorageDirectory();
File f = new File(sdcard, "/yourfile");
if(!f.exsist()){
f.createNewFile();
//Use outwriter here, outputstream search how to write into a file in java code
}
這篇關(guān)于將網(wǎng)絡(luò)位置保存為 .txt 文件(不使用 GPS)的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!