取得最佳的LocationProvider

Android学习笔记 - 定位篇 (Location) 1.UserLocation能做什么   1.获取用户的位置   2.追踪用户的移动   2.UserLocation的关键API   1.LocationManager:用于管理Android用户定位服务   2.LocationProviders:提供多种定位方式供开发者选择   3.定位方式的分类   1.GPS定位,使用GPS卫星进行定位         2. 阅读详情



 

 

新建一个地图项目。

 

 

在main.xml中:

 

<?xml version="1.0" encoding="utf-8"?>

<LinearLayout

  xmlns:android="http://schemas.android.com/apk/res/android"

  android:orientation="vertical"

  android:layout_width="fill_parent"

  android:layout_height="fill_parent"

  android:background="#3399ff">

  <TextView

     android:id="@+id/fineprovider"

     android:layout_margin="8dp"

     android:layout_width="fill_parent"

     android:layout_height="wrap_content"

     android:textColor="#ffffff"/>

</LinearLayout>

 

 

 

 

 

在MyGPSDemo.java中:

 

package com.li.gprs;

 

import android.app.Activity;

import android.content.Context;

import android.location.Criteria;

import android.location.LocationManager;

import android.os.Bundle;

import android.widget.TextView;

 

public class MyGPSDemo extends Activity {

  private TextView fineProvider = null;

  private LocationManager locationManager = null;

 

  @Override

  public void onCreate(Bundle savedInstanceState) {

     super.onCreate(savedInstanceState);

     super.setContentView(R.layout.main);

     this.fineProvider = (TextView) super.findViewById(R.id.fineprovider);

     this.locationManager = (LocationManager) super

         .getSystemService(Context.LOCATION_SERVICE);

     Criteria criteria = new Criteria() ;

     criteria.setAccuracy(Criteria.ACCURACY_FINE) ; // 使用最准确精度

     criteria.setCostAllowed(false); // 不产生费用

     criteria.setPowerRequirement(Criteria.POWER_LOW); // 耗电量低

     String provider = this.locationManager.getBestProvider(criteria, true);

     this.fineProvider.setText("经过匹配,最佳的Provider为:" + provider) ;

  }

}

 

 

 

 

 

在AndroidManifest.xml中修改权限:

 

<manifest xmlns:android="http://schemas.android.com/apk/res/android"

    package="com.li.gprs"

    android:versionCode="1"

    android:versionName="1.0" >

 

    <uses-sdk

        android:minSdkVersion="8"

        android:targetSdkVersion="15" />

  <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

  <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />

    <application

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name"

        android:theme="@style/AppTheme" >

        <activity

            android:name=".MyGPSDemo"

            android:label="@string/title_activity_my_gpsdemo" >

            <intent-filter>

                <action android:name="android.intent.action.MAIN" />

 

                <category android:name="android.intent.category.LAUNCHER" />

            </intent-filter>

        </activity>

    </application>

 

</manifest>

 

Android 中获取LocationProvider的三种方法和获取定位信息 前言: LocationProvider是位置源的意思,用于提供定位信息。 常用的LocationProvider主要有三种: GPS:通过手机里面的GPS芯片,来利用卫星定位信息的。 network:通过网络来获取位置信息的,主要利用手机的基站,和WiFi节点的位置来大致定位。 passive:是一种被动定位方式,它自己不能获取定位信息,而是利用被系统保存的其他程序所更新的定位信息。 下面我们通过三种方法获取LocationProvider 一、首先是activity_location_provide 阅读详情

相关推荐

使用fused location provider 获取经纬度

这是使用fused location provider获取经纬度的源码。虽然结合了GooglePlayService但是不需要翻就能获取到地址。 注意运行时手机必须支持google play store 虚拟机必须是Google Api System Image才可以。

13.Android学习之传感器与定位服务(三)

在通过调用LocationManager的getAllProviders()方法获取所有的LocationProvider时返回的是List集合,集合中的元素为LocationProvider的名称。为了获取实际的LocationProvider对象,可以通过LocationManager的getProvider()方法。对于位置发生变化的用户,可以在变化后接收到相关的通知。◆LocationProvider定位组件的抽象表示,通过该类可以获取该定位组件的相关信息。...

ttycr的博客 783

【原创】通过Android自带的工具实现当前定位 + 2步搞定getBestProvider返回null的问题

通过Android自带的工具实现当前定位 + 2步搞定getBestProvider返回null的问题 今天用Android自带的LocationManager和Location类实现定位,然而中间却出了点问题,那就是getBestProvider在真机上测试返回null值。查阅了很多方法都没有效果,于是我自己灵机一动想出了较好的解决办法。 基本代码如下 import .... //导入包就不写了 public class MainActivity extends AppCompatActivity { //设置权限用的 private static final int BAI

Android 获取LocationProvider以及获取定位信息

  获取LocationProvider的三种方法 一、获取所有的LocationProvider并用TextView显示出来 //获取显示LocationProvider名称的TextView providerTv = findViewById(R.id.act_provider_tv); //获取位置服务 Location...

lanyu96 4828

使用RepeatModeler和RepeatMasker注释基因组重复序列

重复序列注释有两种常用策略,基于同源序列相似性和基于重复序列结构特征。RepeatMasker是基于同源序列相似性注释序列的常用工具, RepeatModeler可用来从头对基因组的重复序列家族进行建模注释,它的核心组件是RECON和RepatScout。 这篇教程介绍如何使用RepeatModeler从头鉴定基因组的重复序列,之后用RepeatMasker根据自...

xuzhougeng blog 8849

强化学习-----DQN(Deep Q-network)

DQN(Deep Q-Network)是一种基于深度学习和强化学习的算法,由DeepMind提出,用于解决离散动作空间下的马尔科夫决策过程(MDP)问题。它是首个成功将深度学习应用于解决强化学习任务的算法之一。DQN,即深度Q网络(Deep Q-network),是指基于深度学习的Q-Learing算法。那什么是Q-leaning?可以看上一篇文章Q-learning是一种经典的强化学习算法,用于解决马尔可夫决策过程(Markov Decision Process,MDP)中的控制问题。

qq_74722169的博客 2万+

Android中获取LocationProvider的三种方式

1.获取所有可用的LocationProvider: List&lt;String&gt; providerNames = locationManager.getAllProviders(); StringBuilder sb = new StringBuilder(); for(Iterator&lt;String&gt; iterator =...

qq_41700374的博客 2369

串级PID 位置环+速度环

串级PID 位置环+速度环

weixin_62775618的博客 9109

获取LocationProvider

Android的定位信息由LocationProvider对象来提供,该对象代表一个抽象的定位组件。在开始编程之前,需要先获得LocationProvider对象。 一、获取所有可用的LocationProvider LocationManager提供了一个getAllProviders()方法来获取系统所有可用LocationProvider,下面的示例程序将可以列出系统所有的Locatio...

weixin_30511039的博客 221

python:numpy分享(保姆级教程)

创建数组:array和ndarray、rand()、randn()、arange()、randint()、uniform()astype()基础函数:ceil()、floor()、rint()、argmax()、argmin()、cumsum()、cumprod()numpy 是数据分析必不可少的第三方库,具有高性能的特点,多用于做数组分析。内置函数:ceil()、floor()、rint()主要用于数组计算,支持多维数组。array和ndarray。比较函数:all、any。去重函数:unique。

sulin123123的博客 1729

动态对抗Zygisk-IL2CppDumper:Unity游戏安全新策略

本文深入探讨了对抗Zygisk-IL2CppDumper攻击的Unity游戏安全新策略。通过实时内存监控、动态混淆技术和异常行为检测体系,有效防止关键代码被动态提取。文章详细介绍了内存指纹系统、运行时混淆方案和五维特征模型等实用防御手段,帮助开发者提升游戏安全性。

weixin_29325955的博客 305

获取指定的LocationProvider

所需权限:

liu537192的专栏 655

【大数据技术干货】(还不懂数仓,数据中心?看这一篇就够了!)在实际的开发生产中,让你了解企业级数据中心整体架构(DB+ETL+ODS+DW+DM)的各个层次的过程详解,数据联系及功能区分

一 企业级数据中心架构 数据仓库的整体架构,各个系统的元数据通过ETL同步到操作性数据仓库ODS中,对ODS数据进行面向主题域建模形成DW(数据仓库),DM是针对某一个业务领域建立模型,具体用户(决策层)查看DM生成的报表。 二 DB 三 ETL(Extract-Transform-Load) ETL是将业务系统的数据经过抽取、清洗转换之后加载到数据仓库的过程,目的是将企业中的分散、零乱、标准不统一的数据整合到一起,为企业的决策提供分析依据。 ETL是BI项目重要的一个环节。 通常情况下,在BI项目中ET

liuchunhang的博客 1288

Android 地理服务

1.User Location 能做什么 获取用户位置 追踪用户的移动 2.User Location 的关键API Location Manager:用于管理Android的用户定位服务; Location Providers: 提供多种定位方式供开发者选择; 3.获取用户的当前位置 Gps定位: 声明权限:android.permission.ACCESS_FINE_L

yuexin2的专栏 1211

从Raw图像到超分辨率:真实场景下的图像增强全流程指南

通过本文的学习,您已掌握了利用Raw图像实现真实场景超分辨率的完整技术链——从数据生成的“真实感模拟”,到双分支CNN的“细节+色彩”协同建模,再到模型的训练与落地。本文将带您从理论到实践,掌握利用Raw图像实现真实场景超分辨率的核心技术,让您的图像在细节和色彩上都能“更上一层楼”。是相机传感器直接输出的原始数据,保留了最完整的亮度、色彩信息(如Bayer阵列的原始采样),这为超分辨率提供了“富矿级”的信息基础。该分支以低分辨率RGB图像为参考,学习“色彩变换矩阵”,让恢复的细节拥有真实的色彩表现。

FJN110的博客 139

C#操作MySQL从入门到精通(3)——新建数据库、新建表

我们要首先新建一个数据库,并且在数据库中新建一系列的表来管理数据库。

qq_34059233的博客 949

Android之用户定位(二)

    获取最佳的LocationProvider,这个最佳是根据条件相对而言滴     //现在先来取得电子设备中都提供了哪些LocationProvider     List<String> providers = locationManager.getAllProvider();     for(Iterator iterator = providers.iter...

84

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

用户定位

User Location的作用 1. 获取用户的位置 2. 追踪用户的移动 USer Location的关键API 1. Location Manager: 用于管理Android的用户定位服务 2. Location Provider: 提供多种定位方式供开发者选择 定位方式的分类: 1 GPS 定位: 使用 GPS 定位,需要声明如下权限: android.permissio

daozhongyang的专栏 2727

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

LinePhone3.2.7(android端最新版本) sip客户端

SIP客户端For android:LinePhone3.2.7(最新版本),官网地址:http://www.linphone.org/

定位(2):选择最好的provider

1.获取最佳的Location Provider GPS    NETWORK    PASSIVE     在AndroidManifest.xml中声明权限: &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/&gt; &lt;uses-permission androi...

ze_nana的专栏 277

SIMATIC S7-1200, S7-1500 PID 控制[手册]

SIMATIC S7-1200, S7-1500 PID 控制[手册]

android固定gps,初探Android平台上的定位服务(GPS)

特别声明:以下所有操作都别忘记了加上权限:sp;LocationManager通过LocationManager可以实现设备的定位、跟踪和趋近提示。它不需要你直接来实例化,我们可以通过Context.getSystemService(Context.LOCATION_SERVICE). 来获得LocationManager实例。常用属性和方法属性和方法描述GPS_PROVIDER静态字符串常量,表...

weixin_30227789的博客 694

android6.23 locate定位服务

public class MainActivity extends AppCompatActivity { private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState);

waynee 492

Android使用GPS

2019独角兽企业重金招聘Python工程师标准>>> ...

weixin_34336526的博客 246

google 地图定位 用到的一些类以及一些方法

哈哈 这个是我的第一篇文章,是我自学的笔记,希望写下来理清思路同时也跟大家分享,不好之处望大家理解! 1,LocationManager LocationManager:获取位置信息的途径,常用的有两种:GPS和NETWORK。GPS定位更精确,缺点是只能在户外使用,耗电严重,并且返回用户位置信息的速度远不能满足用户需求。NETWORK通过基站和Wi-Fi信号来获取位置信息,室内室外均可用,速

小沈的专栏 823

“21 天好习惯”第一期-8

来记录今天我学了些什么,我觉得挺有意思的 一.位置服务 1.获取LocationProvider(常用的LocationProvider有gps,network,passive) 看我项目结构 MainActivity代码如下(注释编号1,2,3分别是三种获取方式,运行结果分别对应(1)(2)(3)) import android.location.Criteria; import android.location.LocationManager; imp

qq_45682662的博客 514
上一篇: 取得全部的LocationProvider
下一篇: 申请Google Map服务
Android人生
博客等级 码龄14年 14粉丝 184原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值