结果:

1.启动后有时会闪退,后来重新做的工程就好了。原因不明(可能与地理反码有关)。

2.原文是用的GOOGLE地图显示位置,但在咱们这里好像不行,改为百度,但百度用的是HTML文件。太麻烦了,大家自己看百度API吧。

3.打开二个权限,不过我看了一下工程自动就是打上对号的(Access coarse location、Access fine location)。

相关资料:

官网地址  http://docwiki.embarcadero.com/RADStudio/XE5/en/Mobile_Tutorial:_Using_Location_Sensors_(iOS_and_Android)

实例代码:

 unit Unit1;

 interface

 uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, System.Sensors,
System.Sensors.Components, FMX.WebBrowser, FMX.Controls.Presentation,
FMX.StdCtrls; type
TForm1 = class(TForm)
Button1: TButton;
WebBrowser1: TWebBrowser;
LocationSensor1: TLocationSensor;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
procedure Button1Click(Sender: TObject);
procedure LocationSensor1LocationChanged(Sender: TObject; const OldLocation,
NewLocation: TLocationCoord2D);
private
{ Private declarations }
FGeocoder: TGeocoder;//定义地理编码对象
procedure OnGeocodeReverseEvent(const Address: TCivicAddress);//定义地理编码事件
public
{ Public declarations }
end; var
Form1: TForm1; implementation {$R *.fmx}
{$R *.NmXhdpiPh.fmx ANDROID} procedure TForm1.Button1Click(Sender: TObject);
begin
LocationSensor1.Active := True;
end; procedure TForm1.LocationSensor1LocationChanged(Sender: TObject;
const OldLocation, NewLocation: TLocationCoord2D);
var
URLString: String;
begin
//显示经纬度
Label2.Text := Format('纬度:%2.6f', [NewLocation.Latitude]);
Label3.Text := Format('经度:%2.6f', [NewLocation.Longitude]);
//地图显示位置
// URLString := Format('https://maps.google.com/maps?q=%s,%s',
// [Format('%2.6f', [NewLocation.Latitude]), Format('%2.6f', [NewLocation.Longitude])]);
// WebBrowser1.Navigate(URLString);
//地理编码功能
if not Assigned(FGeocoder) then
begin
if Assigned(TGeocoder.Current) then
FGeocoder := TGeocoder.Current.Create;
if Assigned(FGeocoder) then
FGeocoder.OnGeocodeReverse := OnGeocodeReverseEvent;
end;
if Assigned(FGeocoder) and not FGeocoder.Geocoding then
FGeocoder.GeocodeReverse(NewLocation);
end; //地理编码事件具体实现
procedure TForm1.OnGeocodeReverseEvent(const Address: TCivicAddress);
begin
label4.Text := Format('行政区:%s', [Address.AdminArea]);
label5.Text := Format('国家代码:%s', [Address.CountryCode]);
label6.Text := Format('国家名称:%s', [Address.CountryName]);
label7.Text := Format('特征名称:%s', [Address.FeatureName]);
label8.Text := Format('地区:%s', [Address.Locality]);
label9.Text := Format('邮政编码:%s', [Address.PostalCode]);
label10.Text := Format('分行政区:%s', [Address.SubAdminArea]);
label11.Text := Format('分地区:%s', [Address.SubLocality]);
label12.Text := Format('分大街:%s', [Address.SubThoroughfare]);
label13.Text := Format('大街:%s', [Address.Thoroughfare]);
end; end.

Android实例-LocationSensor位置传感器(XE8+小米2)的更多相关文章

  1. Android实例-操作摄像头(XE8+小米2)

    结果: 1.同样是照相,自己的程序设置为高质量时刷新慢,而小米手机的相机那真心反映快呀. 2.就算我设置为最高质量,可相片也没有小米手机的相片大.我最大是2000*1000,而小米可以做到3000*2 ...

  2. Android实例-手机震动(XE8+小米2)

    相关资料:http://blog.csdn.net/laorenshen/article/details/41148843 结果: 1.打开Vibrate权限为True. 2.规律震动我没感觉出来,有 ...

  3. Android实例-MotionSensor加速度(XE8+小米2)

    结果: 1. 实例代码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classe ...

  4. Android实例-消息框(XE8+小米2)

    方法一支持. 方法二与方法三都是三方单元,功能相同. 方法4与方法5报错,提示平台不支持. 第三方单元一: unit Android.JNI.Toast; // Java bridge class i ...

  5. Android实例-实现扫描二维码并生成二维码(XE8+小米5)

    相关资料: 第三方资料太大没法写在博文上,请下载CSDN的程序包. 程序包下载: http://download.csdn.net/detail/zhujianqiangqq/9657186 注意事项 ...

  6. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)

    注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...

  7. Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)

    相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...

  8. 45个android实例源码

    分享45个android实例源码,很好很强大http://www.apkbus.com/android-20978-1-1.html andriod闹钟源代码http://www.apkbus.com ...

  9. 分享45个android实例源码,很好很强大

    分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...

随机推荐

  1. hbase 使用备忘

    hbase是基于hadoop的,所以hbase服务器必须启动hadoop,这点很重要. 当然hbase其实只用到了dadoop的一个组件 1. 启动hadoop-dfs 在主上执行如下命令,可以把主和 ...

  2. http://jingyan.baidu.com/article/7908e85c74d85faf491ad260.html

    http://jingyan.baidu.com/article/7908e85c74d85faf491ad260.html

  3. BZOJ 3997 TJOI2015 组合数学

    分析一下样例就可以知道,求的实际上是从左下角到右上角的最长路 因为对于任意不在这个最长路的上的点,都可以通过经过最长路上的点的路径将这个点的价值减光 (可以用反证法证明) 之后就是一个非常NOIP的D ...

  4. BZOJ 4003 JLOI2015 城池攻占

    做法和APIO2012派遣 那道题目类似 在树上DFS,维护当前子树的小根堆 因为需要合并孩子们的信息,使用左偏树就可以了 每次弹出死亡骑士,对剩余骑士打上奖励标记 至于标记的下传和更改,只需要每次在 ...

  5. 【转】wireshark过滤规则

    WireShark过滤语法 1.过滤IP,如来源IP或者目标IP等于某个IP 例子:ip.src eq 192.168.1.107 or ip.dst eq 192.168.1.107或者ip.add ...

  6. javaweb学习总结(四十六)——Filter(过滤器)常见应用

    一.统一全站字符编码 通过配置参数charset指明使用何种字符编码,以处理Html Form请求参数的中文问题 1 package me.gacl.web.filter; 2 3 import ja ...

  7. 新的HTTP框架:Daraja Framework

    https://www.habarisoft.com/daraja_framework.html

  8. Android 使用split函数进行多个空格分割

    在项目中经常会遇到按字符分割字符串的情况,可以使用String对象的split函数进行分割. 先看实际情况: String str = "关键词1 关键词2 关键词3"; Stri ...

  9. windows下配置环境变量时,在cmd窗口执行配置的命令时无效的原因

    一个原因肯定就是配置错误,这个就要自己仔细去检查了,如果确信配置正确,可能是你的cmd窗口在环境变量配置之前就打开的,在配置好环境变量之后,在cmd窗口执行命令是看不到效果的,可以关掉cmd窗口再重新 ...

  10. 利用VC/VS的安装目录找到C/C++库函数实现的源代码

    2013-07-03 20:08:57 大多开发软件的装目录下都有很多有价值的东西,比如help文档.user guide.src文件等.今天在VS的安装目录下发现了库函数的源文件,这些文件中有对所有 ...