[android] 百度地图开发 (三).定位当前位置及getLastKnownLocation获取location总为空问题

article/2025/7/11 16:36:06

       前一篇百度地图开发讲述"(二).定位城市位置和城市POI搜索",主要通过监听对象MKSearchListener类实现城市兴趣点POI(Point of Interest)搜索。该篇讲述定位当前自己的位置及使用getLastKnownLocation获取location总时为空值的问题

一. 定位当前位置的原理及实现

      定位当前位置可以通过LBS(Location Based Service,基于位置的服务),主要工作原理是利用无线网络Network或GPS定位方式确定移动设备所在的位置。
      其基本步骤如下:(参考郭神《Android第一行代码》)

      1.先实例LocationManager,getSystemService(Context.LOCATION_SERVICE)再确定获取系统的定位服务;
      2.选择位置提供器,通常会使用LocationManager.NETWORK_PROVIDER网络定位(精准度差、耗电少)或LocationManager.GPS_PROVIDER实现GPS定位(精准度高、耗电多);
      3.然后通过LocationManager的getLastKnownLocation()函数,它选择位置提供器provider得到Location对象;
      4.此时你已经获取了地理位置,如果手机移动可以通过LocationManager的另一个函数requestLocationUpdates()方法获取动态的位置信息;
      5.获取当前Location后需要加载到百度地图中,可以通过GeoPoint设置当前位置经度和纬度,并使用MyLocationOverlay载入该数据及添加当前位置覆盖物。

      其核心代码如下所示:

//定位
private Button button1; 
private LocationManager locationManager;
private String provider;/*** 定位自己位置 onCreate函数中点击按钮事件*/
button1.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {//获取所有位置提供器locationManager =  (LocationManager) getSystemService(Context.LOCATION_SERVICE);List<String> providerList = locationManager.getProviders(true);if(providerList.contains(LocationManager.NETWORK_PROVIDER)) { //网络提供器provider = LocationManager.NETWORK_PROVIDER;} else if(provider.contains(LocationManager.GPS_PROVIDER)) { //GPS提供器provider = LocationManager.GPS_PROVIDER;} else {Toast.makeText(MainActivity.this, "No location provider to use",Toast.LENGTH_SHORT).show();return;}//获取到记录当前位置Location location = locationManager.getLastKnownLocation(provider);if(location!=null) {//定位我的位置MapController controller = mapView.getController();controller.setZoom(16);//latitude 纬度 longitude 经度GeoPoint point =  new GeoPoint((int) (location.getLatitude()*1E6),(int) (location.getLongitude()*1E6));controller.setCenter(point); //设置地图中心mapView.getOverlays().clear(); //清除地图上所有覆盖物MyLocationOverlay locationOverlay = new MyLocationOverlay(mapView);LocationData locationData = new LocationData();locationData.latitude = location.getLatitude(); //纬度locationData.longitude = location.getLongitude(); //经度locationOverlay.setData(locationData);//添加覆盖物mapView.getOverlays().add(locationOverlay);mapView.refresh(); //刷新}
}
     运行效果如下图所示:
    

二. 定位当前位置的问题


      但是此时你可能会遇到两个问题:
      第一个问题是有时候百度地图不能定位到当前位置,究其原因我发现代码获取的location总为空值,即:

      Location location = locationManager.getLastKnownLocation(provider);
      第二个问题就是在能定位当前位置的情况下,获取的位置总是存在偏移,向左下方偏移一定方位。
      其中第一个问题在getLastKnownLocation(provider)总是获取Null,据说是该函数获取的是上一次Location,而且它不是一次就能定位成功的,需要多次定位才能实现。通过在getLastKnownLocation()函数后添加循环多次定位如下代码:
location = locationManager.getLastKnownLocation(provider);
while(location  == null)  
{  mgr.requestLocationUpdates("gps", 60000, 1, locationListener);  
}  
      其中locationListener是消息监听,具体代码如下所示,当位置发生变化时自定义函数显示新经纬坐标。参考:stackoverflow
private final LocationListener locationListener = new LocationListener() {  //位置发生改变后调用  public void onLocationChanged(Location location) {   //更新当前设备的新位置信息showLocation(location);}  //provider 被用户关闭后调用  public void onProviderDisabled(String provider) {  }  //provider 被用户开启后调用  public void onProviderEnabled(String provider) {         }  //provider 状态变化时调用  public void onStatusChanged(String provider, int status, Bundle extras) {  }  
};
     但是很遗憾的是我采用这种方法并没有解决该问题,这就引出了“三.定位当前位置(源码)”内容。通过另外一种百度地图获取当前位置的方法实现,通过设置LocationClient获取,而且能解决这里提到的两个问题且相对精确的实现定位。

三. 定位当前位置(源码)


     此种方法参考xiaanming大神的博客,推荐大家阅读,讲述的非常好尤其是其实现细节,我主要是阐述该问题及提供一个可行方法罢了。
        http://blog.csdn.net/xiaanming/article/details/11380619
     主要通过locSDK的LocationClient实现显示当前位置,同时此种方法如果遇到没有显示地图。其原因是:首先需要在AndroidManifest.xml中添加如下代码。
      参考:http://bbs.csdn.net/topics/390382448

<application><activity></activity>....<serviceandroid:name="com.baidu.location.f"android:enabled="true"android:process=":remote" ></service>
</application>
      1.运行效果如下图所示。
      它能获取当前位置,并且通过监听函数5秒间隔获取一次;
      public class BDLocationListenerImpl implements BDLocationListener
      在监听函数中富国flag!=1表示没有点击“定位”按钮则不实现监听定位当前位置功能;同时结合前面第二篇文章POI搜索及城市定位功能。

      下载地址Demo:http://download.csdn.net/detail/eastmount/8349191

    
    
     
 2.注意需要引入SDK包括LocSDK_3.1.jar和liblocSDK3.so,其工程结构如下所示:

     
      3.MainActivity.java文件
public class MainActivity extends Activity {//BMapManager 对象管理地图、定位、搜索功能private BMapManager mBMapManager;  private MapView mapView = null;               //地图主控件 private MapController mMapController = null;  //地图控制 MKMapViewListener mMapListener = null;        //处理地图事件回调 private MKSearch mMKSearch;                   //定义搜索服务类//搜索private EditText keyWordEditText;  private EditText cityEditText;private Button queryButton;private static StringBuilder sb;  private MyLocationOverlay myLocationOverlay;//定位private Button button1; private LocationManager locationManager;private String provider;//方法二 定位位置private BDLocation myLocation;  private LocationData mLocData;        //用户位置信息 private LocationClient mLocClient;    //定位SDK的核心类 private MyLocationOverlay locationOverlay = null;  //我的图层private PopupOverlay pop;             //弹出pop 我的位置private int flag=0;                   //标记变量 定位我的位置=1 POI为2@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);/*** 创建对象BMapManager并初始化操作* V2.3.1中init(APIKey,null) V2.4.1在AndroidManifest中赋值AK* 注意 初始化操作在setContentView()前*/mBMapManager = new BMapManager(getApplication());  mBMapManager.init(null); setContentView(R.layout.activity_main);  //获取对象mapView = (MapView) findViewById(R.id.map_view);  cityEditText = (EditText) findViewById(R.id.city_edittext);keyWordEditText = (EditText) findViewById(R.id.keyword_edittext);queryButton = (Button) findViewById(R.id.query_button);button1 = (Button) findViewById(R.id.button1);//地图初始化mMapController = mapView.getController();   //获取地图控制器mMapController.enableClick(true);           //设置地图是否响应点击事件mMapController.setZoom(16);                 //设置地图缩放级别mapView.setBuiltInZoomControls(true);       //显示内置缩放控件/*** 定位自己位置*/ //方法二button1.setOnClickListener(new OnClickListener() {@Overridepublic void onClick(View v) {flag = 1;locationManager =  (LocationManager) getSystemService(Context.LOCATION_SERVICE);//设置缩放级别 级别越高地图显示精细MapController controller = mapView.getController();controller.setZoom(16);//实例化定位服务 LocationClient类必须在主线程中声明 并注册定位监听接口mLocClient = new LocationClient(getApplicationContext());  mLocClient.registerLocationListener(new BDLocationListenerImpl()); /** * LocationClientOption 该类用来设置定位SDK的定位方式。 */  LocationClientOption option = new LocationClientOption();  option.setOpenGps(true); //打开GPRS  option.setAddrType("all"); //返回的定位结果包含地址信息  option.setCoorType("bd09ll"); //返回的定位结果是百度经纬度,默认值gcj02  option.setPriority(LocationClientOption.GpsFirst); // 设置GPS优先  option.setScanSpan(5000);   //设置发起定位请求的间隔时间为5000ms  option.disableCache(false); //禁止启用缓存定位mLocClient.setLocOption(option);  //设置定位参数mLocClient.start();  // 调用此方法开始定位  //定位图层初始化mapView.getOverlays().clear();    locationOverlay= new MyLocationOverlay(mapView);  //实例化定位数据,并设置在我的位置图层  mLocData = new LocationData();  locationOverlay.setData(mLocData); //添加定位图层  mapView.getOverlays().add(locationOverlay);  //修改定位数据后刷新图层生效  mapView.refresh(); }});/*** 初始化MKSearch 调用城市和POI搜索  */mMKSearch = new MKSearch();mMKSearch.init(mBMapManager, new MySearchListener()); queryButton.setOnClickListener(new OnClickListener() {  @Override  public void onClick(View v) {  if(flag==1) {pop.hidePop();flag = 2;}mMapController = mapView.getController();mMapController.setZoom(10);  sb = new StringBuilder();  //内容清空  //输入正确城市关键字String city = cityEditText.getText().toString().trim();  String keyWord = keyWordEditText.getText().toString().trim();  if(city.isEmpty()) { //默认城市设置为贵阳city="贵阳";}//如果关键字为空只搜索城市 GEO搜索 if(keyWord.isEmpty()) {mMKSearch.geocode(city, city); //具体地址和城市 geocode(adress, city)} else {//搜索城市+关键字 mMKSearch.setPoiPageCapacity(10);  //每页返回POI数mMKSearch.poiSearchInCity(city, keyWord); }}  });  }/** * 定位接口,需要实现两个方法  * 参考 http://blog.csdn.net/xiaanming/article/details/11380619*/  public class BDLocationListenerImpl implements BDLocationListener {  /** * 接收异步返回的定位结果,参数是BDLocation类型参数 */  @Override  public void onReceiveLocation(BDLocation location) {  if (location == null || flag != 1) {  return;  }  MapController controller = mapView.getController();//设置经纬度MainActivity.this.myLocation = location;    mLocData.latitude = location.getLatitude();  mLocData.longitude = location.getLongitude();  GeoPoint point = new GeoPoint((int) (location.getLatitude() * 1E6),(int) (location.getLongitude() * 1E6));controller.setCenter(point);//如果不显示定位精度圈,将accuracy赋值为0即可  //mLocData.accuracy = location.getRadius();  mLocData.direction = location.getDerect();  mLocData.accuracy = 0;//将定位数据设置到定位图层里  locationOverlay.setData(mLocData);  //更新图层数据执行刷新后生效  mapView.refresh();  //覆盖物if(flag==1) {//添加图形pop = new PopupOverlay(mapView, new PopupClickListener() { @Overridepublic void onClickedPopup(int index) {}});Bitmap[] bitmaps = new Bitmap[3];try {bitmaps[0] = BitmapFactory.decodeResource(getResources(),R.drawable.left);bitmaps[1] = BitmapFactory.decodeResource(getResources(),R.drawable.middle);bitmaps[2] = BitmapFactory.decodeResource(getResources(),R.drawable.right);} catch (Exception e) {e.printStackTrace();}pop.showPopup(bitmaps, point, 18);}      }  /** * 接收异步返回的POI查询结果,参数是BDLocation类型参数 */  @Override  public void onReceivePoi(BDLocation poiLocation) {  }  }  @Overrideprotected void onResume() {mapView.onResume();if (mBMapManager != null) {mBMapManager.start();}super.onResume();}@Overrideprotected void onDestroy() {mapView.destroy();if (mBMapManager != null) {mBMapManager.destroy();mBMapManager = null;}super.onDestroy();}@Overrideprotected void onPause() {mapView.onPause();if (mBMapManager != null) {mBMapManager.stop();}super.onPause();}	/** * 内部类实现MKSearchListener接口,用于实现异步搜索服务 */  public class MySearchListener implements MKSearchListener {  /** * 根据经纬度搜索地址信息结果 * 同时mMKSearch.geocode(city, city)搜索城市返回至该函数* * @param result 搜索结果 * @param iError 错误号(0表示正确返回) */  @Override  public void onGetAddrResult(MKAddrInfo result, int iError) {  if (result == null) {  return;  }  StringBuffer sbcity = new StringBuffer();  sbcity.append(result.strAddr).append("\n");   //经纬度所对应的位置  mapView.getOverlays().clear();            //清除地图上已有的所有覆盖物  mMapController.setCenter(result.geoPt);       //置为地图中心//添加原点并刷新LocationData locationData = new LocationData();locationData.latitude = result.geoPt.getLatitudeE6();locationData.longitude = result.geoPt.getLongitudeE6();myLocationOverlay = new MyLocationOverlay(mapView);myLocationOverlay.setData(locationData);mapView.getOverlays().add(myLocationOverlay);mapView.refresh();// 通过AlertDialog显示地址信息new AlertDialog.Builder(MainActivity.this)  .setTitle("显示当前城市地图")  .setMessage(sbcity.toString())  .setPositiveButton("关闭", new DialogInterface.OnClickListener() {  public void onClick(DialogInterface dialog, int whichButton) {  dialog.dismiss();  }  }).create().show();}  /** * POI搜索结果(范围检索、城市POI检索、周边检索) *  * @param result 搜索结果 * @param type 返回结果类型(11,12,21:poi列表 7:城市列表) * @param iError 错误号(0表示正确返回) */  @Override  public void onGetPoiResult(MKPoiResult result, int type, int iError) {  if (result == null) {  return;  }    //获取POI并显示mapView.getOverlays().clear(); PoiOverlay poioverlay = new PoiOverlay(MainActivity.this, mapView);  //显示POIpoioverlay.setData(result.getAllPoi()); //设置搜索到的POI数据  mapView.getOverlays().add(poioverlay);  //兴趣点标注在地图上mapView.refresh(); //设置其中一个搜索结果所在地理坐标为地图的中心  if(result.getNumPois() > 0) {  MKPoiInfo poiInfo = result.getPoi(0);  mMapController.setCenter(poiInfo.pt);  }  //添加StringBuffer 遍历当前页返回的POI (默认只返回10个)sb.append("共搜索到").append(result.getNumPois()).append("个POI\n");  for (MKPoiInfo poiInfo : result.getAllPoi()) {  sb.append("名称:").append(poiInfo.name).append("\n");}// 通过AlertDialog显示当前页搜索到的POI  new AlertDialog.Builder(MainActivity.this)  .setTitle("搜索到的POI信息")  .setMessage(sb.toString())  .setPositiveButton("关闭", new DialogInterface.OnClickListener() {  public void onClick(DialogInterface dialog, int whichButton) {  dialog.dismiss();  }  }).create().show();}  /** * 驾车路线搜索结果 *  * @param result 搜索结果 * @param iError 错误号(0表示正确返回) */  @Override  public void onGetDrivingRouteResult(MKDrivingRouteResult result, int iError) {  }  /** * 公交换乘路线搜索结果 *  * @param result 搜索结果 * @param iError 错误号(0表示正确返回) */  @Override  public void onGetTransitRouteResult(MKTransitRouteResult result, int iError) {  }  /** * 步行路线搜索结果 *  * @param result 搜索结果 * @param iError 错误号(0表示正确返回) */  @Override  public void onGetWalkingRouteResult(MKWalkingRouteResult result, int iError) {  }@Overridepublic void onGetBusDetailResult(MKBusLineResult arg0, int arg1) {// TODO Auto-generated method stub}@Overridepublic void onGetPoiDetailSearchResult(int arg0, int arg1) {// TODO Auto-generated method stub}@Overridepublic void onGetShareUrlResult(MKShareUrlResult arg0, int arg1, int arg2) {// TODO Auto-generated method stub}@Overridepublic void onGetSuggestionResult(MKSuggestionResult arg0, int arg1) {// TODO Auto-generated method stub	}}  }
     4.布局文件activity_main.xml,同时添加图片left.png、middle.png和right.png
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:tools="http://schemas.android.com/tools"android:id="@+id/container"android:layout_width="match_parent"android:layout_height="match_parent"android:background="#000000"tools:context="com.example.baidumapshow.MainActivity"tools:ignore="MergeRootFrame" ><!-- 顶部搜索 --><RelativeLayout android:id="@+id/MyLayout_top"android:orientation="horizontal" android:layout_width="fill_parent"android:layout_height="40dp" android:layout_alignParentTop="true"android:gravity="center"><LinearLayout  android:orientation="horizontal"  android:layout_width="fill_parent"  android:layout_height="wrap_content"    android:background="@null"  android:padding="0dip" >  <EditText android:id="@+id/city_edittext"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_gravity="center_vertical"android:layout_marginLeft="5dp"android:background="#ffffff" android:textSize="22dp" android:hint="输入城市"android:layout_weight="15" /><EditText android:id="@+id/keyword_edittext"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_gravity="center_vertical"android:layout_marginLeft="5dp"android:background="#ffffff" android:textSize="22dp" android:hint="输入关键词"android:layout_weight="25" />  <Button android:id="@+id/query_button"  android:layout_width="wrap_content"  android:layout_height="wrap_content"  android:layout_gravity="center_vertical"   android:textColor="#ffffff"android:textSize="20dp"android:text="搜索" />  </LinearLayout> </RelativeLayout><!-- 底部添加按钮 -->  <RelativeLayout  android:id="@+id/MyLayout_bottom"  android:orientation="horizontal"   android:layout_width="fill_parent"  android:layout_height="50dp"  android:layout_alignParentBottom="true"  android:gravity="center">  <LinearLayout   android:layout_width="match_parent"  android:layout_height="match_parent"  android:orientation="horizontal"  android:layout_alignParentBottom="true" >  <Button  android:id="@+id/button1"  android:layout_width="wrap_content"  android:layout_height="match_parent"  android:layout_weight="1"  android:textColor="#ffffff"android:text="定位" />  </LinearLayout>  </RelativeLayout>  <!-- 显示图片 --><RelativeLayoutandroid:id="@+id/Content_Layout" android:orientation="horizontal"android:layout_width="fill_parent" android:layout_height="fill_parent"android:layout_above="@id/MyLayout_bottom" android:layout_below="@id/MyLayout_top"android:gravity="center"><com.baidu.mapapi.map.MapView  android:id="@+id/map_view"android:layout_width="fill_parent"  android:layout_height="fill_parent"  android:clickable="true" /></RelativeLayout>
</RelativeLayout>
      5.设置AndroidMainfest.xml权限及服务,同时设置百度地图APIKey,第一篇文章有详细讲述。
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"package="com.example.baidumapshow"android:versionCode="1"android:versionName="1.0" ><uses-sdkandroid:minSdkVersion="19"android:targetSdkVersion="19" /><!-- 获取网络状态  --><uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /><!-- 访问网络 --><uses-permission android:name="android.permission.INTERNET" /><!-- 获取WiFi状态 --><uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /><uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /><!-- 允许程序写入外部存储,如SD卡上写文件 --><uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /><uses-permission android:name="android.permission.WRITE_SETTINGS" /><!-- 读取电话状态 --><uses-permission android:name="android.permission.READ_PHONE_STATE" /><uses-permission android:name="android.permission.CALL_PHONE" /><!-- 获取精确位置 GPS芯片接收卫星的定位信息,定位精度达10米以内 --><uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /><!-- 通过WiFi或移动基站的方式获取用户错略的经纬度信息 --><uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /><!-- 获取模拟定位信息 --><uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" /><uses-permission android:name="android.permission.ACCESS_GPS" /><applicationandroid:allowBackup="true"android:icon="@drawable/ic_launcher"android:label="@string/app_name"android:theme="@style/AppTheme" ><meta-data   android:name="com.baidu.lbsapi.API_KEY"  android:value="QwaNhFQ0ty2QmdYh3Nrr0gQx"></meta-data> <activityandroid:name="com.example.baidumapshow.MainActivity"android:label="@string/app_name" ><intent-filter><action android:name="android.intent.action.MAIN" /><category android:name="android.intent.category.LAUNCHER" /></intent-filter></activity><serviceandroid:name="com.baidu.location.f"android:enabled="true"android:process=":remote" ></service></application></manifest>
      最后希望文章对大家有所帮助,刚刚接触android开发百度地图,而且还是使用V2.4.1版本,如果有错误或不足之处,还请海涵!建议大家看看官方文档和百度提供的Demo.文章主要参考百度官方文档、xiaanming大神博客和郭神《Android第一行代码》及我前面的两篇文章.
      下载地址:http://download.csdn.net/detail/eastmount/8349191
        [android] 百度地图开发 (一).申请AK显示地图及解决显示空白网格问题 
       [android] 百度地图开发 (二).定位城市位置和城市POI搜索 

     (By:Eastmount 2015-01-11 夜2点 http://blog.csdn.net/eastmount/

http://chatgpt.dhexx.cn/article/1fLyboLk.shtml

相关文章

Android进阶之路 - 定位当前位置、获取经纬度

最近又遇到定位场景&#xff0c;需要上传经纬度&#xff0c;正好同事写了&#xff0c;我就记录一下方便你我他 ~ ~ 今年开始用的kt比较多&#xff0c;所以篇内用的kt&#xff0c;见谅见谅 前情悉知 获取当前位置时&#xff0c;需要判断用户是否授权&#xff0c;这里用到的是 …

vue-amap实现实现初始化并定位当前位置,搜索,定位,增加点标记

实现如图展示&#xff0c;初始化并定位当前位置&#xff0c;搜索&#xff0c;定位&#xff0c;增加点标记 下载vue 1.vue页设置 如果是新版web-js的密钥&#xff0c;有配套的安全秘钥&#xff0c;则需要另外在created加入&#xff0c;否则会报undefined window._AMapSecurity…

vue3定位当前位置,获取当前位置的经纬度

vue3定位当前位置&#xff0c;获取当前位置的经纬度 注意事项&#xff08;访问地址必须是https&#xff09;获取当前位置经纬度 注意事项&#xff08;访问地址必须是https&#xff09; 在vue.config.js文件内设置https:true&#xff0c;然后重启一下项目 获取当前位置经纬度 …

新建文本文档

使用百度地图&#xff0c;定位你当前位置并显示 1、准备 注册百度开发者账号到百度地图开放平台创建应用&#xff08;as获取SHA1值&#xff09; 2、将sdk整到你的项目中去 - 在你app的gradle.build中添加 dependencies {...... compile files(libs/baidumapapi_base_v4_0…

web端定位:获取当前地理位置

2019独角兽企业重金招聘Python工程师标准>>> 方法一:html5原生提供的定位: 讲解:在支持HTML5的浏览器下,navigator对象下有一个属性----geolocation,而geolocation属性又有个方法getCurrentPosition(回调函数1,回调函数2)可以通过浏览器向设备发起定位请求,浏…

uniapp 之定位当前位置 (uni.getLocation,腾讯地图,javascript)

第一种 uniapp uniapp 封装的方法可以拿到城&#xff0c;市&#xff0c;县&#xff0c;经纬度。 实例&#xff1a; //获取位置GetLOcation: function() {var that this;uni.getLocation({type: gcj02,success: (res) > {console.log(res)var latitude parseFloat(res.la…

爆款专栏《Python 黑科技》目录导航丨进度:12/50

《Python 快速入门专栏丨掌握基础》和《Python 黑科技丨练习应用》由 CSDN 博客专家丨全站排名 Top 8 的硬核博主 不吃西红柿 倾力打造&#xff0c;旨在帮助大家快速入门掌握 Python。 更有学习资料&#xff0c;简历和 PPT 模板&#xff0c;微信公众号 【信息技术智库】关注我&…

安卓12解除进程限制方法汇总

一、关于安卓12 使用VMOS PRO 借助电脑激活步骤 第一步&#xff0c;使用usb线将手机连接至电脑。 第二步&#xff0c;打开手机的“开发者选项”&#xff0c;打开USB调试开关&#xff0c;确保手机已进入USB调试模式。 第三步&#xff0c;将激活程序包&#xff08;vmos_activa…

电脑技巧:推荐五款非常棒的小众软件,值得收藏

目录 1、Foodie&#xff08;美食相机&#xff09; 2、黑阈APP 3、Sleep Cycle 睡眠助手APP 4、烧杯——化验APP 5、123看图器 今天小编给大家分享五款非常棒的小众软件&#xff0c;生活中非常实用&#xff0c;感兴趣的朋友欢迎收藏&#xff01; 1、Foodie&#xff08;美食相…

永恒之黑漏洞复现

永痕之黑 1. 永恒之黑漏洞相关信息 漏洞介绍 https://nvd.nist.gov/vuln/detail/CVE-2020-0796 漏洞影响版本&#xff1a; Windows 10 Version 1903 for 32-bit Systems Windows 10 Version 1903 for x64-based Systems Windows 10 Version 1903 for ARM64-based Systems Wi…

手机技巧:推荐一款手机省电、提升流畅度APP

目录 软件详情 基本介绍 软件功能 软件特色 使用方法 软件对比 结论 今天给大家推荐一款手机省电、提升流畅度APP&#xff0c;感兴趣的朋友可以下载一下&#xff01; 软件详情 黑阈app是一款非常实用的系统优化类手机APP。使用它能够禁止软件后台运行耗电&#xff0c;既…

linux usb 黑 白 名单_安卓手机如何一键提升手机性能?用黑阈

安卓手机现状 安卓现在的旗舰机并不比苹果差&#xff0c;但是依然对手机小白很不友好&#xff0c;安卓属于开源&#xff0c;自由度较大&#xff0c;可供发挥的空间更高。需要一定基础才能充分利用安卓的性能。而苹果依然是针对小白的&#xff0c;系统会自行优化&#xff0c;自由…

如何root安卓手机_安卓手机如何一键提升手机性能?用黑阈

安卓手机现状 安卓现在的旗舰机并不比苹果差&#xff0c;但是依然对手机小白很不友好&#xff0c;安卓属于开源&#xff0c;自由度较大&#xff0c;可供发挥的空间更高。需要一定基础才能充分利用安卓的性能。而苹果依然是针对小白的&#xff0c;系统会自行优化&#xff0c;自由…

黑阈使用方法

一、从各大应用市场载「 黑阈 」。 二、切换到「 使用 」的页面&#xff0c;选择「 进入黑阈 」 三、打开「 开发者选项 」跟 「 USB调试 」 四、连接 USB &#xff0c;允许 USB 调试 五、电脑打开下面这个网页&#xff0c;下载相应的 SDK。 https://developer.android.goo…

使用树莓派3b+作为黑阈激活器

黑阈&#xff08;y&#xff09;不需要 root 就能待机&#xff08;App Standby&#xff0c;Android 6.0 引入&#xff0c;部分设备不支持&#xff09;或强行停止应用&#xff0c;防止应用持续运行。 黑阈不处理非“黑阈清单”内应用。当您启动应用&#xff0c;使用完退出&#x…

枚举类型是什么

C语言详解 - 枚举类型 注&#xff1a;以下全部代码的执行环境为VC 6.0 在程序中&#xff0c;可能需要为某些整数定义一个别名&#xff0c;我们可以利用预处理指令#define来完成这项工作&#xff0c;您的代码可能是&#xff1a; #define MON 1 #define TUE 2 #define WED 3 …

ts枚举类

参考官方文档:https://www.tslang.cn/docs/handbook/enums.html 理解:枚举是列举固定几个值,直接定义变量的话的话可以随意定义&#xff0c;枚举只能使用你定义好的几个值,枚举是个类&#xff0c;定义的值是基本类型,类能有更多操作 例如你定义一个方法接收一个参数&#xff0…

Java 枚举类型原理分析为什么枚举比用静态变量多消耗两倍的内存

一 起源&#xff1a;枚举是一种特殊的数据类型&#xff0c;一般用来列举有限个、同类型的常量。它能保证参数的安全性&#xff0c;如方法声明传入的参数&#xff0c;必须是指定枚举中的常量。但是Android开发文档指出&#xff0c;使用枚举会比使用静态变量多消耗2倍内存。为什么…

java枚举转json

1、背景 java后端的枚举类型&#xff0c;要展示到前端&#xff0c;提供给用户进行下拉选择&#xff0c;java后端需要封装enum为json字符串提供给前端&#xff0c;需要首先将枚举类型转为list&#xff0c;然后再转为json字符串。 2、方案 方案也很简单&#xff0c;使用EnumSe…

枚举类的使用

文章目录 前言一、自定义枚举类二、使用enum定义枚举类1.Enum类的主要方法2.实现接口的枚举类 前言 1&#xff09; 类的对象只有有限个&#xff0c;确定的。举例如下&#xff1a; 星期&#xff1a;Monday(星期一)、…、Sunday(星期天) 性别&#xff1a;Man(男)、Woman(女) 季节…