将网络位置保存为.txt文件(不使用GPS)
我是android编程的初学者。 我的研究生项目是关于跟踪移动设备,我需要代码来保存位置(不使用GPS)作为文本文件。 有人建议我这样做的代码。 这对我来说是一个很大的帮助。
尝试这个。
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 }
唯一的方法是与电话管理员一起玩,看看你可以获得有关手机信号塔或网络的信息。 每个网络塔都有唯一的ID,因此您可以根据信号强度和人员位置的内容得到近似估计值。
我打赌这将是有趣和棘手的业务。
- 如何在Parse查询中包含超时?
- 在推送通知错误“notificationBuilder.setContentText(currentText).setNumber(++ numMessages);”中找不到符号
- 如何用Java(Android)在图像上写文本
- Android camera2.params.face矩形放置在canvas上
- 迭代Map 时出现ConcurrentModificationException
- Android图片库视图的来源,包括缩放缩放,触摸滑动等
- Appium logcat捕获失败:生成ENOENT(路径中没有空格)
- GridView获取项目
- Android:在一个单独的线程中输入对话框时Wait()主线程