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

网站如何验收广告代发平台

网站如何验收,广告代发平台,网站建设题库,深圳专业网站建设排名在Unity使用低功耗蓝牙通信#xff08;BLE#xff09;需要用到设备的位置信息。但是调用Input.location.Start()程序会闪退。 解决办法#xff1a;调用原生安卓接口。 参见《Unity2021通过aar调用Android方法》编写一个aar插件gpsplugin#xff0c;在插件中提供获取GPS位…在Unity使用低功耗蓝牙通信BLE需要用到设备的位置信息。但是调用Input.location.Start()程序会闪退。 解决办法调用原生安卓接口。  参见《Unity2021通过aar调用Android方法》编写一个aar插件gpsplugin在插件中提供获取GPS位置的接口StartGPSLocation插件代码如下 package com.example.gpsplugin;import android.app.Activity; import android.content.Context; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; import android.os.Bundle; import android.widget.Toast;public class GPSPluginInstance {private LocationManager locationManager;private LocationListener locationListener;private static final int REQUEST_LOCATION_PERMISSION 1;double latitude 0.0;double longitude 0.0;public int Add(int i, int j) {return i j;}private static Activity unityActivity;public static void receiveUnityActivity(Activity tActivity) {unityActivity tActivity;}public void Toast(String msg) {Toast.makeText(unityActivity, msg, Toast.LENGTH_SHORT).show();}public void StartGPSLocation() {// 初始化 LocationManagerlocationManager (LocationManager) unityActivity.getSystemService(Context.LOCATION_SERVICE);// 创建 LocationListenerif(locationListener null){locationListener new LocationListener() {Overridepublic void onLocationChanged(Location location) {if (location ! null) {latitude location.getLatitude();longitude location.getLongitude();}}Overridepublic void onStatusChanged(String provider, int status, Bundle extras) {// 状态改变时调用}Overridepublic void onProviderEnabled(String provider) {// 提供者启用时调用}Overridepublic void onProviderDisabled(String provider) {// 提供者禁用时调用}};}locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 0, locationListener);} }AndroidManifest.xml中添加蓝牙和位置权限注意Android12以上和之前的版本不一样 uses-permission android:nameandroid.permission.BLUETOOTH_SCAN /uses-permission android:nameandroid.permission.BLUETOOTH_CONNECT / uses-permission android:nameandroid.permission.BLUETOOTH_ADMIN/uses-permission android:nameandroid.permission.BLUETOOTH/uses-feature android:nameandroid.hardware.bluetooth_le android:requiredfalse/uses-permission android:nameandroid.permission.ACCESS_FINE_LOCATION/uses-permission android:nameandroid.permission.ACCESS_COARSE_LOCATION/ Unity代码在使用Input.location.Start()的地方替换成StartGPSLocation就行了 public class BLEBluetoothGunMgr : MonoBehaviour {void Start(){InitializePlugin(com.example.gpsplugin.GPSPluginInstance);}public void GetPos(){ //Input.location.Start()StartGPSLocation();}void InitializePlugin(string pluginName){unityClass new AndroidJavaClass(com.unity3d.player.UnityPlayer);unityActivity unityClass.GetStaticAndroidJavaObject(currentActivity);_pluginInstance new AndroidJavaObject(pluginName);if (_pluginInstance null){Debug.Log(Plugin Instance Error);}_pluginInstance.CallStatic(receiveUnityActivity, unityActivity);}public void Toast(){if (_pluginInstance ! null){_pluginInstance.Call(Toast, Hi,from Unity);}}public void StartGPSLocation(){if (_pluginInstance ! null){_pluginInstance.Call(StartGPSLocation);}} }
http://www.w-s-a.com/news/136955/

相关文章:

  • 专业开发网站设计找人做网页需要多少钱
  • 手机购物网站 建站网站建设网站制作网站设计
  • 基于iview的网站开发模板小程序制作需要什么语言
  • 精美网站设计保定建行网站首页登录
  • 网站建设常见问题做网站保存什么格式最好
  • 营销型网站建设与网页设计网站建设 amp 找VX cp5173
  • 新网站该如何做网站优化呢儿童手工
  • 湖北现代城市建设集团网站搜索引擎优化的作用
  • 上海做网站吧开一家软件开发公司需要什么
  • 阿里巴巴网站建设改图片建设厅官方网站河南
  • 邓砚谷电子商务网站建设镇江网
  • 网站空间支持什么程序工作服款式
  • 网站单页品牌网站建设 蝌蚪5小
  • 怎么做外贸网站需注意哪些做电脑系统的网站
  • 网站建设介绍推广用语河南网站优化外包服务
  • 课程网站模板贵州省城乡与建设厅网站
  • 网站模板及源码谁家网站用户体验做的好
  • 做网站的技术要求搜索栏在wordpress菜单上位置
  • 如何给网站弄ftpwordpress怎么添加关键词描述
  • 成都工程建设信息网站金科网站建设
  • 传媒公司 网站开发厦门网站建设门户
  • 宿城区建设局网站做网站的绿色背景图
  • 网站空间托管合同 .doc网站开发团队 组建
  • 网站建设书本信息it运维服务
  • 四核网站建设设计网站流程
  • ui设计网站设计与网页制作视频教程wordpress插件漏洞利用
  • 网站建设公司排名前十做网站的最终目的
  • 选择网站开发公司的标准中国网站建设市场规模
  • 衣服网站建设策划书广州住房和城乡建设部网站
  • 微商城科技淄博网站建设优化seo