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 ...
随机推荐
- HDU4608+模拟
简单的模拟题. 暴力枚举 /* 模拟 */ #include<algorithm> #include<iostream> #include<string.h> #i ...
- highcharts 多数据+切换
var highchartsOptions = { chart:{ renderTo:'container' }, title:{ text:'指标数据' }, tooltip:{ pointForm ...
- 影响pogo pin连接器使用寿命的因素
精细化.安装简易化及使用寿命长是现在数码电子产品的趋势发展,pogo pin连接器体积小而且弹簧伸缩式设计,可以更好的缩小数码电子产品的尺寸并且连接安装更加的简单方便,因此pogo pin连接器得到了 ...
- Android TextView结合SpannableString使用
super.onCreate(savedInstanceState); TextView txtInfo = new TextView(this); SpannableString ss = new ...
- Memcache+Cookie解决分布式系统共享登录状态------------------------------Why Memcached?
每个用户请求向IIS发送一个请求,但IIS服务器的请求数有限,cpu支持的线程数有限,如果一秒钟向这台服务器发送10000次,那么则一般就会有问题,考虑集群, 请求数据分流,几台服务器共同对应一个公共 ...
- [ffmpeg 扩展第三方库编译系列] 关于 mingw32 下编译libcaca
在编译前最好先看一下帮助 ./configure --help 开始编译 ./configure --disable-shared --disable-cxx \ --disable-csharp ...
- Android开发之ContentProvider的简单使用
ContentProvider,内容提供者 官网结构图: 作为四大组件之一的ContentProvider,主要是用于应用间数据共享使用的. ContentProvider把应用的数据封装起来,然后提 ...
- Ruby Gem命令
Gem是一个管理Ruby库和程序的标准包,它通过Ruby Gem(如 http://rubygems.org/ )源来查找.安装.升级和卸载软件包,非常的便捷. Ruby 1.9.2版本默认已安装Ru ...
- 函数fseg_create_general
申请一个段 /**********************************************************************//** Creates a new segm ...
- poj3671
首先容易想到的是LIS,但是n<=30000,所以肯定要优化: 壮哉单调队列又登场了: 然后再找一个最长不上升序列并求两者最大值即可,复杂度O(n logn); 应该说这是解题通法了,但再回头看 ...