如何获取好友的位置(经度和纬度)?

发布于 2024-12-11 21:18:02 字数 1437 浏览 0 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

离鸿 2024-12-18 21:18:02

你永远无法仅仅通过手机号码获得别人的位置,这就像跟踪一样。

Google 提供了一项名为 Latitude 的服务,这是一种更好、更合法的方式。


否则,如果两个用户具有相同的应用程序,则他们应该将其位置(从 Cell ID 或 GPS 获得)推送到 Web 服务器(您将处理该服务器)。然后,您可以使用网络服务交换位置坐标。作为参考,请查看此处表 1


检测 SMS 消息的代码

public class IncomingSmsCapture extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();       
SmsMessage[] msgs = null;
String data = "";           
if (bundle != null)
{
    Object[] pdus = (Object[]) bundle.get("pdus");
    msgs = new SmsMessage[pdus.length];           
    for (int i=0; i<msgs.length; i++){
    msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);               
    String sender = msgs[i].getOriginatingAddress();      
    data = msgs[i].getMessageBody().toString(); 
    // parse the data and extract the location, then convert to an Address using the GeoCoder. 
}    }   }   }

You can never get someone elses location simply from the mobile number, that is like stalking.

Google provide a service called Latitude which is a much better, legal way of doing this.


Otherwise, if the two uses have the same application, they should push their location (obtained from the Cell ID or GPS) to a Web Server (which you will handle). You can then exchange the location coordinates using your web-service. For reference, have a look at the Table 1 over here


Code to detect SMS messages

public class IncomingSmsCapture extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();       
SmsMessage[] msgs = null;
String data = "";           
if (bundle != null)
{
    Object[] pdus = (Object[]) bundle.get("pdus");
    msgs = new SmsMessage[pdus.length];           
    for (int i=0; i<msgs.length; i++){
    msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);               
    String sender = msgs[i].getOriginatingAddress();      
    data = msgs[i].getMessageBody().toString(); 
    // parse the data and extract the location, then convert to an Address using the GeoCoder. 
}    }   }   }
雨的味道风的声音 2024-12-18 21:18:02

使用 CellID。CellID 是与特定小区(手机所连接的无线电塔)相关联的号码。在大多数情况下,这是距离您所在位置最近的塔。因此,通过了解这座塔的位置,您就可以大致知道手机的位置。

为了更好的想法请看这里

将位置添加到非 GPS 手机:引入 CellID

现在,如果您知道您朋友的 cellId,那么您就可以知道他们的位置。另一种方式

开发基于位置的服务:介绍 J2ME 的位置 API

Use CellID.A CellID is a number which is associated with a specific cell (the radio tower to which your handset is connected). In most cases, this is the closest tower to your location. So by knowing the location of this tower, then you can know approximately where the handset is.

For better Idea Take a look at here

Adding location to a non GPS phone: introducing CellID

Now if you know your friends cellId then you can know their location.Another way

Developing Location Based Services: Introducing the Location API for J2ME

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文