Android实例-LocationSensor位置传感器(XE8+小米2)

结果:
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)的更多相关文章
- Android实例-操作摄像头(XE8+小米2)
结果: 1.同样是照相,自己的程序设置为高质量时刷新慢,而小米手机的相机那真心反映快呀. 2.就算我设置为最高质量,可相片也没有小米手机的相片大.我最大是2000*1000,而小米可以做到3000*2 ...
- Android实例-手机震动(XE8+小米2)
相关资料:http://blog.csdn.net/laorenshen/article/details/41148843 结果: 1.打开Vibrate权限为True. 2.规律震动我没感觉出来,有 ...
- Android实例-MotionSensor加速度(XE8+小米2)
结果: 1. 实例代码: unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classe ...
- Android实例-消息框(XE8+小米2)
方法一支持. 方法二与方法三都是三方单元,功能相同. 方法4与方法5报错,提示平台不支持. 第三方单元一: unit Android.JNI.Toast; // Java bridge class i ...
- Android实例-实现扫描二维码并生成二维码(XE8+小米5)
相关资料: 第三方资料太大没法写在博文上,请下载CSDN的程序包. 程序包下载: http://download.csdn.net/detail/zhujianqiangqq/9657186 注意事项 ...
- Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(无图)
注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYinYinQi ...
- Android实例-调用GOOGLE的TTS实现文字转语音(XE7+小米2)(XE10.1+小米5)
相关资料: 注意:在手机上必须选安装文字转语音引擎“google Text To Speech”地址:http://www.shouji56.com/soft/GoogleWenZiZhuanYuYi ...
- 45个android实例源码
分享45个android实例源码,很好很强大http://www.apkbus.com/android-20978-1-1.html andriod闹钟源代码http://www.apkbus.com ...
- 分享45个android实例源码,很好很强大
分享45个android实例源码,很好很强大 http://www.apkbus.com/android-20978-1-1.html 分享45个android实例源码,很好很强大http://www ...
随机推荐
- jquery中事件重复绑定以及解绑问题
一般的情况下,对于这种情况,我们常规的思路是,先解绑,再绑定,如下: $(selector).unbind('click').bind('click',function(){....}); 当这样会有 ...
- Android studio 下的 NDK 配置方法和注意事项
http://blog.csdn.net/u013598660/article/details/47341963
- Servlet课程0425(六) 不经过验证直接跳转---session实现不同页面之间共享数据
在地址栏直接输入http://localhost:8080/myWebSite/wel 会发现页面也能跳转,只不过用户名和密码都为空,这是不可以的,因为没有经过验证非法登录了 Welcome,hell ...
- Android init进程概述
init进程,其程序位于根文件系统中,在kernle自行启动后,其中的 start_kernel 函数把根文件系统挂载到/目录后,在 rest_init 函数中通过 kernel_thread(ker ...
- AIDL与stub
Stub翻译成中文是存根的意思,注意Stub对象是在被调用端进程,也就是服务端进程,至此,服务端aidl服务端得编码完成了. stub是为了方便client,service交互而生成出来的代码.A ...
- HTML5学习(五)----SVG
参考教程地址:http://www.w3school.com.cn/html5/html_5_svg.asp HTML5 支持内联 SVG. 什么是SVG? SVG 指可伸缩矢量图形 (Scalabl ...
- grep 同时满足多个关键字和满足任意关键字
grep 同时满足多个关键字和满足任意关键字 ① grep -E "word1|word2|word3" file.txt 满足任意条件(word1.word2和word ...
- POJ 2586 Y2K Accounting Bug(贪心)
题目连接:http://poj.org/problem?id=2586 题意:次(1-5.2-6.3-7.4-8.5-9.6-10.7-11.8-12),次统计的结果全部是亏空(盈利-亏空<0) ...
- poj 3295 Tautology (构造)
题目:http://poj.org/problem?id=3295 题意:p,q,r,s,t,是五个二进制数. K,A,N,C,E,是五个运算符. K:&& A:||N:! C:(!w ...
- hibernate缓存:一级缓存和二级缓存
1.什么是缓存? 缓存是介于物理数据源与应用程序之间,是对数据库中的数据复制一份临时放在内存中的容器,其作用是为了减少应用程序对物理数据源访问的次数,从而提高了应用程序的运行性能.Hibernate在 ...