satellitelist是啥意思

satellitelist是啥意思,第1张

satellite list

卫星列表

If you select this option, highlight the name of the satellite in the list at the left side of the dialog.

如果你选择这个选项,在目录中选择卫星名称,使它高亮显示。

如有帮助请采纳,

如对本题有疑问可追问,Good luck!

android-satellite-menu实现点击主按钮,会d出多个围绕着主按钮排列的子按钮,从而形成一个卫星d出式菜单。子按钮d出和消失的动画效果都很棒。这种d出式菜单按钮应用在Path2.0中。

用法

在你的view xml中添加组件定义,如下示例:

属性有:

satelliteDistance  The distance of items from the center button

totalSpacingDegree  The degree between the first and the last item.

closeOnClick  Defines if the menu shall collapse after clicking on a menu item.

expandDuration  The duration of expand and collapse operations in milliseconds.

当在你的View XML定义之后,可按以下代码添加子菜单:

Each menu item takes the ID of the item and the drawable resource for the item.

In order to listen clicks on items:

一、LocationManager

LocationMangager,位置管理器。要想 *** 作定位相关设备,必须先定义个LocationManager。我们可以通过如下代码创建LocationManger对象。

LocationManger locationManager=(LocationManager)this.getSystemService(Context.LOCATION_SERVICE)

二、LocationListener

LocationListener,位置监听,监听位置变化,监听设备开关与状态

private LocationListener locationListener=new LocationListener() {

/**

* 位置信息变化时触发

*/

public void onLocationChanged(Location location) {

updateView(location)

Log.i(TAG, "时间:"+location.getTime())

Log.i(TAG, "经度:"+location.getLongitude())

Log.i(TAG, "纬度:"+location.getLatitude())

Log.i(TAG, "海拔:"+location.getAltitude())

}

/**

* GPS状态变化时触发

*/

public void onStatusChanged(String provider, int status, Bundle extras) {

switch (status) {

//GPS状态为可见时

case LocationProvider.AVAILABLE:

Log.i(TAG, "当前GPS状态为可见状态")

break

//GPS状态为服务区外时

case LocationProvider.OUT_OF_SERVICE:

Log.i(TAG, "当前GPS状态为服务区外状态")

break

//GPS状态为暂停服务时

case LocationProvider.TEMPORARILY_UNAVAILABLE:

Log.i(TAG, "当前GPS状态为暂停服务状态")

break

}

}

/**

* GPS开启时触发

*/

public void onProviderEnabled(String provider) {

Location location=lm.getLastKnownLocation(provider)

updateView(location)

}

/**

* GPS禁用时触发

*/

public void onProviderDisabled(String provider) {

updateView(null)

}

}

三、Location

Location,位置信息,通过Location可以获取时间、经纬度、海拔等位置信息。上面采用locationListener里面的onLocationChanged()来获取location,下面讲述如何主动获取location。

Location location=locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER)

system.out.println("时间:"+location.getTime())

system.out.println("经度:"+location.getLongitude())

注意:Location location=new Location(LocationManager.GPS_PROVIDER)方式获取的location的各个参数值都是为0。

四、GpsStatus.Listener

GpsStatus.Listener ,GPS状态监听,包括GPS启动、停止、第一次定位、卫星变化等事件。

//状态监听

GpsStatus.Listener listener = new GpsStatus.Listener() {

public void onGpsStatusChanged(int event) {

switch (event) {

//第一次定位

case GpsStatus.GPS_EVENT_FIRST_FIX:

Log.i(TAG, "第一次定位")

break

//卫星状态改变

case GpsStatus.GPS_EVENT_SATELLITE_STATUS:

Log.i(TAG, "卫星状态改变")

//获取当前状态

GpsStatus gpsStatus=lm.getGpsStatus(null)

//获取卫星颗数的默认最大值

int maxSatellites = gpsStatus.getMaxSatellites()

//创建一个迭代器保存所有卫星

Iterator<GpsSatellite>iters = gpsStatus.getSatellites().iterator()

int count = 0

while (iters.hasNext() &&count <= maxSatellites) {

GpsSatellite s = iters.next()

count++

}

System.out.println("搜索到:"+count+"颗卫星")

break

//定位启动

case GpsStatus.GPS_EVENT_STARTED:

Log.i(TAG, "定位启动")

break

//定位结束

case GpsStatus.GPS_EVENT_STOPPED:

Log.i(TAG, "定位结束")

break

}

}

}

//绑定监听状态

lm.addGpsStatusListener(listener)

五、GpsStatus

GpsStatus,GPS状态信息,上面在卫星状态变化时,我们就用到了GpsStatus。

//实例化

GpsStatus gpsStatus = locationManager.getGpsStatus(null)// 获取当前状态

//获取默认最大卫星数

int maxSatellites = gpsStatus.getMaxSatellites()

//获取第一次定位时间(启动到第一次定位)

int costTime=gpsStatus.getTimeToFirstFix()

//获取卫星

Iterable<GpsSatellite>iterable=gpsStatus.getSatellites()

//一般再次转换成Iterator

Iterator<GpsSatellite>itrator=iterable.iterator()

六、GpsSatellite

GpsSatellite,定位卫星,包含卫星的方位、高度、伪随机噪声码、信噪比等信息。

//获取卫星

Iterable<GpsSatellite>iterable=gpsStatus.getSatellites()

//再次转换成Iterator

Iterator<GpsSatellite>itrator=iterable.iterator()

//通过遍历重新整理为ArrayList

ArrayList<GpsSatellite>satelliteList=new ArrayList<GpsSatellite>()

int count=0

int maxSatellites=gpsStatus.getMaxSatellites()

while (itrator.hasNext() &&count <= maxSatellites) {

GpsSatellite satellite = itrator.next()

satelliteList.add(satellite)

count++

}

System.out.println("总共搜索到"+count+"颗卫星")

//输出卫星信息

for(int i=0i<satelliteList.size()i++){

//卫星的方位角,浮点型数据

System.out.println(satelliteList.get(i).getAzimuth())

//卫星的高度,浮点型数据

System.out.println(satelliteList.get(i).getElevation())

//卫星的伪随机噪声码,整形数据

System.out.println(satelliteList.get(i).getPrn())

//卫星的信噪比,浮点型数据

System.out.println(satelliteList.get(i).getSnr())

//卫星是否有年历表,布尔型数据

System.out.println(satelliteList.get(i).hasAlmanac())

//卫星是否有星历表,布尔型数据

System.out.println(satelliteList.get(i).hasEphemeris())

//卫星是否被用于近期的GPS修正计算

System.out.println(satelliteList.get(i).hasAlmanac())

}

为了便于理解,接下来模拟一个案例,如何在程序代码中使用GPS获取位置信息。

第一步:新建一个Android工程项目,命名为mygps,目录结构如下

第二步:修改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">

<EditText android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:cursorVisible="false"

android:editable="false"

android:id="@+id/editText"/>

</LinearLayout>

第三步:实用Adnroid平台的GPS设备,需要添加上权限

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

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

第四步:修改核心组件activity,修改内容如下

package com.ljq.activity

import java.util.Iterator

import android.app.Activity

import android.content.Context

import android.content.Intent

import android.location.Criteria

import android.location.GpsSatellite

import android.location.GpsStatus

import android.location.Location

import android.location.LocationListener

import android.location.LocationManager

import android.location.LocationProvider

import android.os.Bundle

import android.provider.Settings

import android.util.Log

import android.widget.EditText

import android.widget.Toast

public class GpsActivity extends Activity {

private EditText editText

private LocationManager lm

private static final String TAG="GpsActivity"@Override

protected void onDestroy() {

// TODO Auto-generated method stub

super.onDestroy()

lm.removeUpdates(locationListener)

}

@Override

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState)

setContentView(R.layout.main)

editText=(EditText)findViewById(R.id.editText)

lm=(LocationManager)getSystemService(Context.LOCATION_SERVICE)

//判断GPS是否正常启动

if(!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)){

Toast.makeText(this, "请开启GPS导航...", Toast.LENGTH_SHORT).show()

//返回开启GPS导航设置界面

Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS)

startActivityForResult(intent,0)

return

}

//为获取地理位置信息时设置查询条件

String bestProvider = lm.getBestProvider(getCriteria(), true)

//获取位置信息

//如果不设置查询要求,getLastKnownLocation方法传人的参数为LocationManager.GPS_PROVIDER

Location location= lm.getLastKnownLocation(bestProvider)

updateView(location)

//监听状态

lm.addGpsStatusListener(listener)

//绑定监听,有4个参数

//参数1,设备:有GPS_PROVIDER和NETWORK_PROVIDER两种

//参数2,位置信息更新周期,单位毫秒

//参数3,位置变化最小距离:当位置距离变化超过此值时,将更新位置信息

//参数4,监听

//备注:参数2和3,如果参数3不为0,则以参数3为准;参数3为0,则通过时间来定时更新;两者为0,则随时刷新

// 1秒更新一次,或最小位移变化超过1米更新一次;

//注意:此处更新准确度非常低,推荐在service里面启动一个Thread,在run中sleep(10000)然后执行handler.sendMessage(),更新位置

lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 1000, 1, locationListener)

}

//位置监听

private LocationListener locationListener=new LocationListener() {

/**

* 位置信息变化时触发

*/

public void onLocationChanged(Location location) {

updateView(location)

Log.i(TAG, "时间:"+location.getTime())

Log.i(TAG, "经度:"+location.getLongitude())

Log.i(TAG, "纬度:"+location.getLatitude())

Log.i(TAG, "海拔:"+location.getAltitude())

}

/**

* GPS状态变化时触发

*/

public void onStatusChanged(String provider, int status, Bundle extras) {

switch (status) {

//GPS状态为可见时

case LocationProvider.AVAILABLE:

Log.i(TAG, "当前GPS状态为可见状态")

break

//GPS状态为服务区外时

case LocationProvider.OUT_OF_SERVICE:

Log.i(TAG, "当前GPS状态为服务区外状态")

break

//GPS状态为暂停服务时

case LocationProvider.TEMPORARILY_UNAVAILABLE:

Log.i(TAG, "当前GPS状态为暂停服务状态")

break

}

}

/**

* GPS开启时触发

*/

public void onProviderEnabled(String provider) {

Location location=lm.getLastKnownLocation(provider)

updateView(location)

}

/**

* GPS禁用时触发

*/

public void onProviderDisabled(String provider) {

updateView(null)

}

}


欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/bake/11401351.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-15
下一篇 2023-05-15

发表评论

登录后才能评论

评论列表(0条)

保存