hi…first…sorry for my english…im trying to test gps on android, i can see long and lat, but just few seconds, then my app crash and close…can be a problem with my device?im using bq aquarius m5…or maybe is a code problem.?..im using this code…thanks for help…
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class gpsmio : MonoBehaviour
{
public Text lonText;
public Text latitudText;
LocationInfo currentGPSPosition;
IEnumerator Start()
{
// First, check if user has location service enabled
if (!Input.location.isEnabledByUser)
yield break;
// Start service before querying location
Input.location.Start();
// Wait until service initializes
int maxWait = 20;
while (Input.location.status == LocationServiceStatus.Initializing && maxWait > 0)
{
yield return new WaitForSeconds(1);
maxWait--;
}
// Service didn't initialize in 20 seconds
if (maxWait < 1)
{
print("Timed out");
yield break;
}
// Connection has failed
if (Input.location.status == LocationServiceStatus.Failed)
{
print("Unable to determine device location");
yield break;
}
else
{
// Access granted and location value could be retrieved
print("Location: " + Input.location.lastData.latitude + " " + Input.location.lastData.longitude + " " + Input.location.lastData.altitude + " " + Input.location.lastData.horizontalAccuracy + " " + Input.location.lastData.timestamp);
//lonText.text = "long:" + Input.location.lastData.longitude.ToString() ;
//latitudText.text ="lat:" + Input.location.lastData.latitude.ToString();
}
// Stop service if there is no need to query location updates continuously
Input.location.Stop();
}
}