【问题标题】:Save network location as a .txt file (Without using GPS)将网络位置保存为 .txt 文件(不使用 GPS)
【发布时间】:2012-04-01 19:11:06
【问题描述】:

我是安卓编程的初学者。我的研究生项目是关于跟踪移动设备的,我需要将位置(不使用 GPS)保存为文本文件的代码。有人建议我这样做的代码。这对我有很大的帮助。

【问题讨论】:

标签: java android geolocation


【解决方案1】:

试试这个。

locationManagerNetwork = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location location2 = locationManagerNetwork
                    .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

     if (location2 != null) {       
                String message = String
                        .format("Yout location : \n Longitude: %1$s \n 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
            }

用于写入 sd 卡

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 
}

【讨论】:

    【解决方案2】:

    这样做的唯一方法是与电话管理器一起玩,看看您可以获得哪些关于手机信号塔或网络的信息。每个网络塔都有唯一的 id,根据信号强度和人的位置信息,您可以从中获得近似估计。

    我敢打赌,这将是一件有趣而棘手的事情。

    【讨论】:

    • 有没有办法使用代码找到大致的网络位置。我尝试了很多代码。没有任何效果。
    • stackoverflow 用户描述的许多代码和方法。请帮帮我兄弟。
    • 您有什么具体问题吗?
    • 我想获取服务提供商网络位置并将其作为 .txt 文件保存到 SD 卡中。
    • 您能否发布一些您从电话经理那里获得的示例数据,从那里我们可能能够找出一些东西
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多