network id是什么locaiton是什么意思

From Wikipedia, the free encyclopedia
This article has multiple issues. Please help
or discuss these issues on the .
This article relies largely or entirely upon a . Relevant discussion may be found on the . Please help
by introducing
to additional sources. (December 2014)
This article has no . Please help by adding an introductory section to this article. For more information, see the , and Wikipedia's . (December 2014)
network, when a
(MS) is switched ON, the
(IMSI) attach procedure is executed. This procedure is required for the
(VLR) to register the MS in the network. If the MS has changed
(LA) while it was powered off the IMSI attach procedure will lead to a .
When the MS is switched on, it searches for a mobile network to connect to. Once the MS identifies its desired network, it sends a message to the network to indicate that it has entered into an idle state. The
(VLR) checks its database to determine whether there is an existing record of the particular subscriber.
If no record is found, the VLR communicates with the subscriber's
(HLR) and obtains a copy of the subscription information. The obtained information is stored in the database of the VLR. Then an acknowledge message is sent to the MS. Steps for IMSI attach procedure are as follows:
The MS will send a Channel Request message to the BSS on the RACH.
The BSS responds on the AGCH with an Immediate Assignment message and assigns an SDCCH to the MS.
The MS immediately switches to the assigned SDCCH and sends a Location Update Request to the BSS. The MS will send either an IMSI or a TMSI to the BSS.
The BSS will acknowledge the message. This acknowledgement only tells the MS that the BTS has received the message, it does not indicate the location update has been processed.
The BSS forwards the Location Update Request to the MSC/VLR.
The MSC/VLR forwards the IMSI to the HLR and requests verification of the IMSI as well as Authentication Triplets.
The HLR will forward the IMSI to the Authentication Center (AuC) and request authentication triplets.
The AuC generates the triplets and sends them along with the IMSI, back to the HLR.
The HLR validates the IMSI by ensuring it is allowed on the network and is allowed subscriber services. It then forwards the IMSI and Triplets to the MSC/VLR.
The MSC/VLR stores the SRES and the Kc and forwards the RAND to the BSS and orders the BSS to authenticate the MS.
The BSS sends the MS an Authentication Request message. The only parameter sent in the message is the RAND.
The MS uses the RAND to calculate the SRES and sends the SRES back to the BSS on the SDCCH in an Authentication Response. The BSS forwards the SRES up to the MSC/VLR.
The MSC/VLR compares the SRES generated by the AuC with the SRES generated by the MS. If they match, then authentication is completed successfully.
The MSC/VLR forwards the Kc for the MS to the BSS. The Kc is NOT sent across the Air Interface to the MS. The BSS stores the Kc and forwards the Set Cipher Mode command to the MS. The CIPH_MOD_CMD only tells the MS which encryption to use (A5/X), no other information is included.
The MS immediately switches to cipher mode using the A5 encryption algorithm. All transmissions are now enciphered. It sends a Ciphering Mode Complete message to the BSS.
The MSC/VLR sends a Location Updating Accept message to the BSS. It also generates a new TMSI for the MS. TMSI assignment is a function of the VLR. The BSS will either send the TMSI in the LOC_UPD_ACC message or it will send a separate TMSI Reallocation Command message. In both cases, since the Air Interface is now in cipher mode, the TMSI is not compromised.
The MS sends a TMSI Reallocation Complete message up to the MSC/VLR.
The BSS instructs the MS to go into idle mode by sending it a Channel Release message. The BSS then deassigns the SDCCH.
The MSC/VLR sends an Update Location message to the HLR. The HLR records which MSC/VLR the MS is currently in, so it knows which MSC to point to when it is queried for the location of the MS.
IMSI detach is the process of detaching a MS from the mobile network to which it was connected. The
detach procedure informs the network that the Mobile Station is switched off or is unreachable.
At power-down the MS requests a signaling channel. Once assigned, the MS sends an IMSI detach message to the VLR. When the VLR receives the IMSI detach-message, the corresponding IMSI is marked as detached by setting the IMSI detach flag. The HLR is not informed of this and the VLR does not acknowledge the MS about the IMSI detach.
If the radio link quality is poor when IMSI detach occurs, the VLR may not properly receive the IMSI-detach request. Since an acknowledgment message is not sent to the MS, it does not make further attempts to send IMSI detach messages. Therefore the GSM network considers the MS to be still attached.
The GSM air-interface, designated Um, transmits network-specific information on specific broadcast channels. This information includes whether the periodic location update is enabled. If enabled, then the MS must send location update requests at time intervals specified by the network. If the MS is switched off, having not properly completed the IMSI detach procedure, the network will consider the MS as switched off or unreachable if no location update is made. In this situation the VLR performs an implicit IMSI detach.
This procedure is used to update the location of the Mobile Station in the network and is described in more detail .
When a mobile station registers in a new VLR, the subscriber's data is deleted from the previous VLR in a cancel location procedure. The HLR initiates the procedure when it receives an 'update location' message from a VLR other than the one in which the MS was located at the time when its location information was last updated in the HLR database. The cancel location procedure can also be initiated with MML commands, with those, for example, that are used for changing the area, or deleting the MS from the HLR.
This section is empty. You can help by . (July 2010)
Moe Rahnema (April 1993).
(PDF). IEEE Communications Magazine.
: Hidden categories:在最新的库文件。将liblocSDK4d.so文件拷贝到libs/armeabi目录下。将locSDK4.2.jar文件拷贝到工程的libs目录下,并在工程属性-&Java Build Path-&Libraries中选择“Add JARs”,选定locSDK4.2.jar,确定后返回。这样您就可以在程序中使用百度定位SDK了。
&service android:name=&com.baidu.location.f& android:enabled=&true& android:process=&:remote&&
&/service&
&!-- 这个权限用于进行网络定位--&
&uses-permission android:name=&android.permission.ACCESS_COARSE_LOCATION&&&/uses-permission&
&!-- 这个权限用于访问GPS定位--&
&uses-permission android:name=&android.permission.ACCESS_FINE_LOCATION&&&/uses-permission&
&!-- 用于访问wifi网络信息,wifi信息会用于进行网络定位--&
&uses-permission android:name=&android.permission.ACCESS_WIFI_STATE&&&/uses-permission&
&!-- 获取运营商信息,用于支持提供运营商信息相关的接口--&
&uses-permission android:name=&android.permission.ACCESS_NETWORK_STATE&&&/uses-permission&
&!-- 这个权限用于获取wifi的获取权限,wifi信息会用来进行网络定位--&
&uses-permission android:name=&android.permission.CHANGE_WIFI_STATE&&&/uses-permission&
&!-- 用于读取手机当前的状态--&
&uses-permission android:name=&android.permission.READ_PHONE_STATE&&&/uses-permission&
&!-- 写入扩展存储,向扩展卡写入数据,用于写入离线定位数据--&
&uses-permission android:name=&android.permission.WRITE_EXTERNAL_STORAGE&&&/uses-permission&
&!-- 访问网络,网络定位需要上网--&
&uses-permission android:name=&android.permission.INTERNET& /&
&!—SD卡读取权限,用户写入离线定位数据--&
&uses-permission android:name=&android.permission.MOUNT_UNMOUNT_FILESYSTEMS&&&/uses-permission&
&!--允许应用读取低级别的系统日志文件 --&
&uses-permission android:name=&android.permission.READ_LOGS&&&/uses-permission&
import com.baidu.location.BDLocation;
import com.baidu.location.BDLocationListener;
import com.baidu.location.LocationClient;
import com.baidu.location.LocationClientOption;
import com.baidu.location.BDNotifyListener;//假如用到位置提醒功能,需要import该类
//如果使用地理围栏功能,需要import如下类
import com.baidu.location.BDGeofence;
import com.baidu.location.BDLocationStatusCodes;
import com.baidu.location.GeofenceClient;
import com.baidu.location.GeofenceClient.OnAddBDGeofencesResultListener;
import com.baidu.location.GeofenceClient.OnGeofenceTriggerListener;
import com.baidu.location.GeofenceClient.OnRemoveBDGeofencesResultListener;
使用SDK4.2需要在Mainfest.xml设置Accesskey,设置有误会引起定位和地理围栏服务不能正常使用,必须进行Accesskey的正确设置。
设置AccessKey,在application标签中加入
&meta-data
android:name=&com.baidu.lbsapi.API_KEY&
android:value=&key& /&//key:开发者申请的key
基本定位功能指的根据用户实际需求,返回用户当前位置的基础定位服务。包含GPS和网络定位(Wi-Fi和基站定位)功能。基本定位功能同时还支持结合定位结果的反地理编码功能,离线定位,位置提醒功能和地理围栏功能。
此处需要注意:LocationClient类必须在主线程中声明。需要Context类型的参数。
Context需要时全进程有效的context,推荐用getApplicationConext获取全进程有效的context
public LocationClient mLocationClient = null;
public BDLocationListener myListener = new MyLocationListener();
public void onCreate() {
mLocationClient = new LocationClient(getApplicationContext());
//声明LocationClient类
mLocationClient.registerLocationListener( myListener );
//注册监听函数
LocationClient类是定位SDK的核心类,具体方法如下:
public LocationClient ( Context )
//须在主线程中声明
设置参数:
public void setLocOption ( LocationClientOption )
参数:配置定位SDK,详见LocationClientOption类。 说明:2.x版本以后的定位提供API接口,用以在API运行过程中,支持热切换配置参数。
注册监听函数:
public void registerLocationListener ( BDLocationListener )
参数:详见BDLocationListener类。 说明:当没有注册监听函数时,无法发起网络请求。
注册位置提醒监听事件:
public void registerNotify ( BDNotifyListener mNotify )
开启/关闭:
public void start();
public void stop();
start:启动定位SDK。 stop:关闭定位SDK。调用stop之后,设置的参数LocationClientOption仍然保留。
发起定位:
public int requestLocation()
发起定位,异步获取当前位置。因为是异步的,所以立即返回,不会引起阻塞。定位结果在ReceiveListener的方法OnReceive方法的参数中返回。
需要注意:当定位SDK从定位依据判定,位置和上一次没发生变化,而且上一次定位结果可用时,则不会发起网络请求,而是返回上一次的定位结果。 返回值:
0:正常发起了定位。
1:服务没有启动。
2:没有监听函数。
6:请求间隔过短。 前后两次请求定位时间间隔不能小于1000ms。
请求离线定位:
离线定位功能:用户请求过得基站定位结果会缓存在本地文件。离线定位结果为缓存结果,精度低于在线的定位结果。
离线定位结果没有地址信息。
public int requestOfflineLocation()
发起离线定位,异步获取当前位置。因为是异步的,所以立即返回,不会引起阻塞。定位结果在ReceiveListener的方法OnReceive方法的参数中返回。
0:正常发起了定位。
1:服务没有启动。
2:没有监听函数。
取消监听函数:
public void unRegisterLocationListener(BDLocationListener listener)
取消监听函数。
位置提醒相关函数:
//注册位置提醒监听事件
public void registerNotify(BDNotifyListener mNotify)
//取消位置提醒监听事件
public void removeNotifyEvent(BDNotifyListener mNotify)
BDLocationListener接口有2个方法需要实现: 1.接收异步返回的定位结果,参数是BDLocation类型参数。
public class MyLocationListener implements BDLocationListener {
public void onReceiveLocation(BDLocation location) {
if (location == null)
StringBuffer sb = new StringBuffer(256);
sb.append(&time : &);
sb.append(location.getTime());
sb.append(&\nerror code : &);
sb.append(location.getLocType());
sb.append(&\nlatitude : &);
sb.append(location.getLatitude());
sb.append(&\nlontitude : &);
sb.append(location.getLongitude());
sb.append(&\nradius : &);
sb.append(location.getRadius());
if (location.getLocType() == BDLocation.TypeGpsLocation){
sb.append(&\nspeed : &);
sb.append(location.getSpeed());
sb.append(&\nsatellite : &);
sb.append(location.getSatelliteNumber());
} else if (location.getLocType() == BDLocation.TypeNetWorkLocation){
sb.append(&\naddr : &);
sb.append(location.getAddrStr());
logMsg(sb.toString());
BDLocation类,封装了定位SDK的定位结果,在BDLocationListener的onReceive方法中获取。通过该类用户可以获取error code,位置的坐标,精度半径等信息。具体方法如下:
获取error code:
public int getLocType ( )
61 : GPS定位结果
62 : 扫描整合定位依据失败。此时定位结果无效。
63 : 网络异常,没有成功向服务器发起请求。此时定位结果无效。
65 : 定位缓存的结果。
66 : 离线定位结果。通过requestOfflineLocaiton调用时对应的返回结果
67 : 离线定位失败。通过requestOfflineLocaiton调用时对应的返回结果
68 : 网络连接失败时,查找本地离线定位时对应的返回结果
161: 表示网络定位结果
162~167: 服务端定位失败
502:key参数错误
505:key不存在或者非法
601:key服务被开发者自己禁用
602:key mcode不匹配
501~700:key验证失败
如果不能定位,请记住这个返回值,并到我们的hi群或者贴吧中交流。若返回值是162~167,请发送邮件至反馈。
获取经纬度坐标:
public double getLatitude ( )
//获取维度
public double getLongitude ( )
//获取经度
获取定位的坐标。坐标的类型在setLocationClientOption方法中设定。
获取定位精度:
public boolean hasRadius ( )
//判断是否有定位精度半径
public float getRadius ( )
//获取定位精度半径,单位是米
获取文字描述的地址(反地理编码):
public String getAddrStr ( )
//获取反地理编码
只有使用网络定位的情况下,才能获取当前位置的反地理编码描述。
自定位SDK2.6版本之后,支持获取省/市/区分级地理信息:
public String getProvince ( )
//获取省份信息
public String getCity ( )
//获取城市信息
public String getDistrict ( )
//获取区县信息
获取手机方向信息:
public float getDirection()
//获得手机方向,范围【0-360】,手机上部正朝向北的方向为0°方向
设置定位参数包括:定位模式(高精度定位模式,低功耗定位模式和仅用设备定位模式),返回坐标类型,是否打开GPS等等。
高精度定位模式:这种定位模式下,会同时使用网络定位和GPS定位,优先返回最高精度的定位结果;
低功耗定位模式:这种定位模式下,不会使用GPS,只会使用网络定位(Wi-Fi和基站定位)
仅用设备定位模式:这种定位模式下,不需要连接网络,只使用GPS进行定位,这种模式下不支持室内环境的定位
LocationClientOption option = new LocationClientOption();
option.setLocationMode(LocationMode.Hight_Accuracy);//设置定位模式
option.setCoorType(&bd09ll&);//返回的定位结果是百度经纬度,默认值gcj02
option.setScanSpan(5000);//设置发起定位请求的间隔时间为5000ms
option.setIsNeedAddress(true);//返回的定位结果包含地址信息
option.setNeedDeviceDirect(true);//返回的定位结果包含手机机头的方向
mLocClient.setLocOption(option);
LocationClientOption类,该类用来设置定位SDK的定位方式,具体方法如下:
设置定位模式:
//Hight_Accuracy高精度、Battery_Saving低功耗、Device_Sensors仅设备(GPS)
public void setLocationMode(LocationMode mode)
设置打开GPS:
setOpenGps( boolean )
设置是否打开gps,使用gps前提是用户硬件打开gps。默认是不打开gps的。
设置是否需要设备方向信息:
//在网络定位中,获取手机机头所指的方向
public void setNeedDeviceDirect(boolean)
设置是否需要地址信息:
使用setIsNeedAddress(boolean)
设置是否要返回地址信息,默认为无地址信息。
public void setAddrType ( String )
String 值为 all时,表示返回地址信息,其他值都表示不返回地址信息。
设置坐标类型:
设置返回值的坐标类型。
public void setCoorType ( String )
我们支持返回若干种坐标系,包括国测局坐标系、百度坐标系,需要更多坐标系请联系我们,需要深度合作。目前这些参数的代码为。因此需要在请求时指定类型,如果不指定,默认返回百度坐标系。注意当仅输入IP时,不会返回坐标。目前这些参数的代码为
返回国测局经纬度坐标系 coor=gcj02
返回百度墨卡托坐标系 coor=bd09
返回百度经纬度坐标系 coor=bd09ll
百度手机地图对外接口中的坐标系默认是bd09ll,如果配合百度地图产品的话,需要注意坐标系对应问题。
有关坐标系的更多问题,请看常见问题
设置产品线名称:
public void setProdName ( String )
设置产品线名称。强烈建议您使用自定义的产品线名称,方便我们以后为您提供更高效准确的定位服务。
设置定位时间间隔:
public void setScanSpan ( int )
//设置定时定位的时间间隔。单位ms
当所设的整数值大于等于1000(ms)时,定位SDK内部使用定时定位模式。调用requestLocation( )后,每隔设定的时间,定位SDK就会进行一次定位。如果定位SDK根据定位依据发现位置没有发生变化,就不会发起网络请求,返回上一次定位的结果;如果发现位置改变,就进行网络请求进行定位,得到新的定位结果。定时定位时,调用一次requestLocation,会定时监听到定位结果。
当不设此项,或者所设的整数值小于1000(ms)时,采用一次定位模式。每调用一次requestLocation( ),定位SDK会发起一次定位。请求定位与监听结果一一对应。
设定了定时定位后,可以热切换成一次定位,需要重新设置时间间隔小于1000(ms)即可。locationClient对象stop后,将不再进行定位。如果设定了定时定位模式后,多次调用requestLocation(),则是每隔一段时间进行一次定位,同时额外的定位请求也会进行定位,但频率不会超过1秒一次。
设置位置提醒接口:
public void registerNotify( BDNotifyListener mNotify )
LocationClient注册位置提醒监听事件
public void removeNotifyEvent( BDNotifyListener mNotify )
LocationClient取消位置提醒监听事件
发起定位请求。请求过程是异步的,定位结果在上面的监听函数onReceiveLocation中获取。
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestLocation();
Log.d(&LocSDK4&, &locClient is null or not started&);
发起离线定位请求。请求过程是异步的,定位结果在上面的监听函数onReceiveLocation中获取。
getLocTypte = BDLocation.TypteOfflineLocation || BDLocation.TypeOfflineLocationFail
表示是离线定位请求返回的定位结果
if (mLocClient != null && mLocClient.isStarted())
mLocClient.requestOfflineLocation();
位置提醒最多提醒3次,3次过后将不再提醒。 假如需要再次提醒,或者要修改提醒点坐标,都可通过函数SetNotifyLocation()来实现。
//位置提醒相关代码
mNotifyer = new NotifyLister();
mNotifyer.SetNotifyLocation(42.37,113.6,3000,&gps&);//4个参数代表要位置提醒的点的坐标,具体含义依次为:纬度,经度,距离范围,坐标系类型(gcj02,gps,bd09,bd09ll)
mLocationClient.registerNotify(mNotifyer);
//注册位置提醒监听事件后,可以通过SetNotifyLocation 来修改位置提醒设置,修改后立刻生效。
//BDNotifyListner实现
public class NotifyLister extends BDNotifyListener{
public void onNotify(BDLocation mlocation, float distance){
mVibrator01.vibrate(1000);//振动提醒已到设定位置附近
//取消位置提醒
mLocationClient.removeNotifyEvent(mNotifyer);
地理围栏服务提供的是基于位置的提醒服务,相对于SDK原来提供的位置提醒功能,地理围栏服务通过SDK本身的内部逻辑,大幅度降低位置提醒服务的功耗情况。通过使用地理围栏服务,第三方APP可以在低能耗的模式下轻松实现位置提醒服务。
此处需要注意:GeofenceClient类必须在主线程中声明。需要Context类型的参数。
Context需要时全进程有效的context,推荐用getApplicationConext获取全进程有效的context。
public GeofenceClient mGeofenceClient = null;
public void onCreate() {
mGeofenceClient = new GeofenceClient(getApplicationContext();
添加围栏回调:OnAddBDGeofencesResultListener
实现如下:
public class AddGeofenceListener implements
OnAddBDGeofencesResultListener {
public void onAddBDGeofencesResult(int statusCode, String geofenceRequestId) {
if (statusCode == BDLocationStatusCodes.SUCCESS) {
//围栏创建成功
}}}
删除围栏回调:OnRemoveBDGeofencesResultListener
实现如下:
public class RemoveFenceListener implements OnRemoveBDGeofencesResultListener {
public void onRemoveBDGeofencesByRequestIdsResult(int statusCode, String[] geofenceRequestIds) {
if (statusCode == BDLocationStatusCodes.SUCCESS) {
//围栏删除成功
}}}
public class GeofenceEnterLister implements OnGeofenceTriggerListener {
public void onGeofenceTrigger(String geofenceRequestId) {
//进入围栏,围栏Id = geofenceRequestId
public void onGeofenceExit(String geofenceRequestId) {
//退出围栏,围栏Id = geofenceRequestId
//注册并开启围栏扫描服务
mGeofenceClient .registerGeofenceTriggerListener(new GeofenceEnterLister());
mGeofenceClient.start();
围栏参数包括:id:围栏Id、x,y:围栏坐标点经纬度、name、半径类型(目前只支持半径在500m以内的围栏)、expir:围栏的有效时间,单位毫秒(最长可以设置1个月)、coordType:坐标类型(COORD_TYPE_BD09、COORD_TYPE_BD09LL、COORD_TYPE_GCJ)、
具体如下:
BDGeofence fence = new BDGeofence.Builder().setGeofenceId(id).
setCircularRegion(x, y, type)
. setExpirationDruation(expir)
. setCoordType(coordType)
.build();
//添加一个围栏:
mGeofenceClient.addBDGeofence(fence, new AddGeofenceListener());
//删除,指定要删除围栏的名字列表
List&String& fences = new ArrayList&String&();
fences.add(fenceId);
mGeofenceClient. removeBDGeofences(fences, new RemoveFenceListener());
定位SDK必须注册GPS和网络的使用权限。
使用定位SDK请保证网络连接通畅(GPS定位方式不需要连网)。
我们强烈建议您设置自己的prodName,并保管好,这样方便我们为您提供更好的定位服务。
若需要返回的定位结果里包含地址信息,请保证网络连接。
定位SDK可以返回bd09、bd09ll、gcj02三种类型坐标,若需要将定位点的位置通过百度Android地图 SDK进行地图展示,请返回bd09ll,将无偏差的叠加在百度地图上。
有的移动设备锁屏后为了省电会自动关闭网络连接,此时网络定位模式的定位失效。此外,锁屏后移动设备若进入cpu休眠,定时定位功能也失效。若您需要实现在cpu休眠状态仍需定时定位,可以用alarmManager 实现1个cpu可叫醒的timer,定时请求定位。
Android开发}

我要回帖

更多关于 内盘和外盘是什么意思 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信