| 12345678910111213141516171819202122232425 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class GPSTool
- {
- //GPS获取地址
- //成功返回:string[]{国,省,市}
- //失败返回:null
- public static string[] GetAddress()
- {
- string[] address = null;
- using (var clsU3D = new AndroidJavaClass("com.unity3d.player.UnityPlayer"))
- {
- using (var objCtx = clsU3D.GetStatic<AndroidJavaObject>("currentActivity"))
- {
- using (var objGPSTool = new AndroidJavaClass("com.example.smartbowlib.GPSTool"))
- {
- address = objGPSTool.CallStatic<string[]>("getAddress", objCtx);
- }
- }
- }
- return address;
- }
- }
|