当前位置: 首页 > news >正文

英雄联盟做的广告视频网站什么是网站维护

英雄联盟做的广告视频网站,什么是网站维护,有没有可以做游戏的网站吗,代理网站建设文章目录 Android 系统定位和高德定位系统定位工具类封装LocationManager使用 高德定位封装高德地图使用 Android 系统定位和高德定位 系统定位 工具类 public class LocationUtils {public static final int REQUEST_LOCATION 0xa1;/*** 判断定位服务是否开启*/public sta… 文章目录 Android 系统定位和高德定位系统定位工具类封装LocationManager使用 高德定位封装高德地图使用 Android 系统定位和高德定位 系统定位 工具类 public class LocationUtils {public static final int REQUEST_LOCATION 0xa1;/*** 判断定位服务是否开启*/public static boolean isOpenLocationServer(Context context) {int locationMode 0;try {locationMode Settings.Secure.getInt(context.getContentResolver(), Settings.Secure.LOCATION_MODE);} catch (Settings.SettingNotFoundException e) {e.printStackTrace();return false;}return locationMode ! Settings.Secure.LOCATION_MODE_OFF;}/*** 判断GPS是否可用*/public static boolean isGPSEnabled(Context context) {LocationManager manager (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);return manager.isProviderEnabled(LocationManager.GPS_PROVIDER);}/*** 判断定位是否可用*/public static boolean isLocationEnabled(Context context) {LocationManager manager (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);return manager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) || manager.isProviderEnabled(LocationManager.GPS_PROVIDER);}/*** 开启位置服务*/public static void openLocation(Activity activity) {activity.startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), REQUEST_LOCATION);}/*** 开启位置服务*/public static void openLocation(Fragment fragment) {fragment.startActivityForResult(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS), REQUEST_LOCATION);}}封装LocationManager public class LocationHelper {private static OnLocationChangeListener mOnLocationChangeListener;private static MyLocationListener mLocationListener;private static LocationManager mLocationManager;private static String mProvider;/*** 注册*/public static void registerLocation(Context context, Nullable OnLocationChangeListener listener) {mOnLocationChangeListener listener;mLocationManager (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);mProvider mLocationManager.getBestProvider(getCriteria(), true);Location lastKnownLocation mLocationManager.getLastKnownLocation(mProvider);if (listener ! null lastKnownLocation ! null) {listener.onLastKnownLocation(lastKnownLocation);}mLocationListener new MyLocationListener();startLocation();}/*** 开始定位*/public static void startLocation() {// 第二个参数更新定位的时间间隔第三个参数更新定位的距离范围mLocationManager.requestLocationUpdates(mProvider, 0, 0, mLocationListener);}/*** 停止定位*/public static void stopLocation() {mLocationManager.removeUpdates(mLocationListener);}/*** 设置定位参数** return {link Criteria}*/private static Criteria getCriteria() {Criteria criteria new Criteria();// 设置定位精确度 Criteria.ACCURACY_COARSE比较粗略Criteria.ACCURACY_FINE则比较精细criteria.setAccuracy(Criteria.ACCURACY_FINE);// 设置是否要求速度criteria.setSpeedRequired(false);// 设置是否允许运营商收费criteria.setCostAllowed(false);// 设置是否需要方位信息criteria.setBearingRequired(false);// 设置是否需要海拔信息criteria.setAltitudeRequired(false);// 设置对电源的需求criteria.setPowerRequirement(Criteria.POWER_LOW);return criteria;}/*** 取消注册*/public static void unregisterLocation() {if (mLocationManager ! null) {if (mLocationListener ! null) {mLocationManager.removeUpdates(mLocationListener);}}mLocationManager null;mLocationListener null;mOnLocationChangeListener null;}public interface OnLocationChangeListener {void onLastKnownLocation(Location location);void onLocationChanged(Location location);}public static class MyLocationListener implements LocationListener {Overridepublic void onLocationChanged(NonNull Location location) {if (mOnLocationChangeListener ! null) {mOnLocationChangeListener.onLocationChanged(location);}}} }public class LocationService extends Service {public static void actionStart(Context context) {context.startService(new Intent(context, LocationService.class));}public static void actionStop(Context context) {context.stopService(new Intent(context, LocationService.class));}SuppressLint(MissingPermission)Overridepublic void onCreate() {super.onCreate();new Thread(() - {Looper.prepare();LocationHelper.registerLocation(getApplicationContext(), new LocationHelper.OnLocationChangeListener() {Overridepublic void onLastKnownLocation(Location location) {if (location ! null) {Log.e(TAG, onLastKnownLocation location);}}Overridepublic void onLocationChanged(Location location) {if (location ! null) {Log.e(TAG, onLocationChanged location);stopSelf();}}});Looper.loop();}).start();}NullableOverridepublic IBinder onBind(Intent intent) {return null;}Overridepublic void onDestroy() {super.onDestroy();LocationHelper.unregisterLocation();} }使用 // 开始定位 LocationService.actionStart(MainActivity.this, start);// 停止定位 LocationService.actionStart(MainActivity.this, stop);// 单次定位 LocationService.actionStart(MainActivity.this, once);高德定位 封装高德地图 public class GDLocationHelper {private static AMapLocationClient locationClient;private static OnLocationChangeListener mOnLocationChangeListener;private static MyLocationListener mListener;public static void register(Context context, Nullable OnLocationChangeListener onLocationChangeListener) {mOnLocationChangeListener onLocationChangeListener;initLocation(context);}private static void initLocation(Context context) {locationClient new AMapLocationClient(context);AMapLocation lastKnownLocation locationClient.getLastKnownLocation();if (lastKnownLocation ! null mOnLocationChangeListener ! null) {mOnLocationChangeListener.onLastKnownLocation(lastKnownLocation);}// 设置定位监听mListener new MyLocationListener();locationClient.setLocationListener(mListener);}public static void startLocation() {locationClient.stopLocation();locationClient.setLocationOption(getDefaultOption(false));locationClient.startLocation();}public static void startOnceLocation() {locationClient.stopLocation();locationClient.setLocationOption(getDefaultOption(true));locationClient.startLocation();}public static void stopLocation() {locationClient.stopLocation();}public static void unregister() {stopLocation();locationClient.onDestroy();locationClient null;mOnLocationChangeListener null;mListener null;}public static AMapLocationClientOption getDefaultOption(boolean isOnce) {AMapLocationClientOption mOption new AMapLocationClientOption();mOption.setLocationMode(AMapLocationClientOption.AMapLocationMode.Hight_Accuracy);//可选设置定位模式可选的模式有高精度、仅设备、仅网络。默认为高精度模式 // mOption.setGpsFirst(false);//可选设置是否gps优先只在高精度模式下有效。默认关闭 // mOption.setHttpTimeOut(30000);//可选设置网络请求超时时间。默认为30秒。在仅设备模式下无效 // mOption.setNeedAddress(true);//可选设置是否返回逆地理地址信息。默认是trueif (isOnce) {mOption.setOnceLocation(true);//可选设置是否单次定位。默认是falsemOption.setOnceLocationLatest(true);//可选设置是否等待wifi刷新默认为false.如果设置为true,会自动变为单次定位持续定位时不要使用} else {mOption.setOnceLocation(false);mOption.setInterval(2_000);//可选设置定位间隔。默认为2秒}mOption.setMockEnable(false); //设置是否允许模拟位置 // AMapLocationClientOption.setLocationProtocol(AMapLocationClientOption.AMapLocationProtocol.HTTP);//可选 设置网络请求的协议。可选HTTP或者HTTPS。默认为HTTP // mOption.setSensorEnable(false);//可选设置是否使用传感器。默认是falsemOption.setWifiScan(true); //可选设置是否开启wifi扫描。默认为true如果设置为false会同时停止主动刷新停止以后完全依赖于系统刷新定位位置可能存在误差mOption.setLocationCacheEnable(true); //可选设置是否使用缓存定位默认为true // mOption.setGeoLanguage(AMapLocationClientOption.GeoLanguage.DEFAULT);//可选设置逆地理信息的语言默认值为默认语言根据所在地区选择语言return mOption;}public static class MyLocationListener implements AMapLocationListener {Overridepublic void onLocationChanged(AMapLocation aMapLocation) {if (mOnLocationChangeListener ! null) {mOnLocationChangeListener.onLocationChanged(aMapLocation);}}}public interface OnLocationChangeListener {void onLastKnownLocation(AMapLocation location);void onLocationChanged(AMapLocation location);} }public class GDLocationService extends Service {private volatile boolean isOnce false;public static void actionStart(Context context) {actionStart(context, null);}public static void actionStart(Context context, String command) {context.startService(new Intent(context, GDLocationService.class).putExtra(command, command));}public static void actionStop(Context context) {context.stopService(new Intent(context, GDLocationService.class));}Overridepublic void onCreate() {super.onCreate();GDLocationHelper.register(getApplicationContext(), new GDLocationHelper.OnLocationChangeListener() {Overridepublic void onLastKnownLocation(AMapLocation location) {if (location ! null) {Log.e(TAG, onLastKnownLocation location.toString());}}Overridepublic void onLocationChanged(AMapLocation location) {if (location ! null) {Log.e(TAG, onLocationChanged location.toString());if (isOnce) {stopSelf();}}}});}Overridepublic int onStartCommand(Intent intent, int flags, int startId) {String command intent.getStringExtra(command);switch (command) {case once:isOnce true;GDLocationHelper.startOnceLocation();break;case stop:GDLocationHelper.stopLocation();break;case start:default:isOnce false;GDLocationHelper.startLocation();break;}return super.onStartCommand(intent, flags, startId);}NullableOverridepublic IBinder onBind(Intent intent) {return null;}Overridepublic void onDestroy() {super.onDestroy();GDLocationHelper.unregister();Log.e(TAG, onDestroy);} }使用 // 开始定位 GDLocationService.actionStart(MainActivity.this, start);// 停止定位 GDLocationService.actionStart(MainActivity.this, stop);// 单次定位 GDLocationService.actionStart(MainActivity.this, once);
http://www.w-s-a.com/news/232532/

相关文章:

  • 沈阳做网站推广的公司唐山哪家做网站好
  • 国外著名网站建设公司WordPress破解怎样主题修复
  • 网站建设济南云畅网络广州电力建设有限公司网站
  • 查看公司信息的网站思特奇是外包公司吗
  • 制作企业网站的目的啥都能看的浏览器
  • 做网站可以用哪些语言如何进行网站运营与规划
  • 做效果图网站有哪些电子商城网站制作数据库
  • 小刘网站建设wordpress调用php文件上传
  • 建设银行对账网站网络营销广告案例
  • 做网站开票是多少个点的票wordpress扫码提交数据库
  • 织梦网站改版需要怎么做企业网站备案管理系统
  • 大规模网站开发语言宁夏建设职业技术学院网站
  • 寻花问柳专注做一家男人爱的网站北京展台设计制作
  • 中卫网站设计做自己的卡盟网站
  • 广州网站推广自助做网站人家直接百度能搜到的
  • 电子商务网站建设目标及利益分析安徽建设厅网站施
  • 制作网站策划书网站建设公司的性质
  • 哪个网站可以做免费宣传简单的网页设计网站
  • 福州专业网站制作公司金湖建设局网站
  • 好的移动端网站模板下载兰州线上广告推广
  • 宁波高端建站深圳品牌营销策划机构
  • 权威网站优化价格建设厅科技中心网站首页
  • 保定模板建站软件腾讯云做淘客网站
  • 单位建设一个网站的费用正规刷手机单做任务网站
  • 北京定制网站价格开网店怎么卖到外国
  • 做网站 后端是谁来做的工程建设指挥部网站
  • wordpress建站 云打印昆明 网站设计
  • 太原网站建设设计网站建设策划书(建设前的市场分析)
  • 哪里有制作网站电商新手入门知识
  • 制作网站的后台文昌网站建设 myvodo