- Home /
WWW didnt work on device ON UNITY 3.3?
i make this code using C Sharp to send the data to the server. it works on the unity simulator but didnt work on android device. im using nexus S and nexus one. Is there any problem with my code? it works on unity 3.0 but in unity 3.3(trail version) it didnt work anymore. using UnityEngine; using System.Collections;
public class SendDetails : MonoBehaviour {
public string url = "test url";
public string key = "test key";
public string urlCheck = "test url";
[HideInInspector]
public bool sent = false;
public bool loading = false;
public void SumUpData(string name, string ic, string contact, int score, int level, float height)
{
loading=true;
WWWForm form = new WWWForm();
form.AddField("key", key);
form.AddField("ic", ic);
form.AddField("username", name);
form.AddField("contact", contact);
form.AddField("score", score.ToString());
form.AddField("level", level.ToString());
form.AddField("height", height.ToString());
WWW www = new WWW(url, form);
StartCoroutine(WaitForRequest(www));
}
public void checkInternet()
{
WWW www = new WWW(url);
StartCoroutine(WaitForRequest(www));
}
IEnumerator WaitForRequest(WWW www)
{
yield return www;
if (www.error == null)
{
Debug.Log("WWW Ok!: " + www.text);
loading=false;
sent = true;
}
else
{
Debug.Log("WWW Error: "+ www.error);
loading=false;
sent = false;
}
}
}
Answer by DaveA · Jun 16, 2011 at 05:39 AM
One thing to try is can you get your content by using Android's web browser (any of them)? I just had this happen to me, where I couldn't see some content in Unity, but tried the browser, didn't see it there either.
The problem stems from something I don't quite understand having to do with DNS (default?) on Android. It doesn't have one or something. Hitting the numeric IP address got me what I needed.
im not quite understand about the hitting the numeric IP address. Did you means that i need to change the ip inside my android or change the url?
public string url = "http://www.google.com"; into public string url = "http://192.168.0.0"; ?
Thanks
Answer by Richard 3 · Nov 16, 2011 at 02:11 PM
Upgrade Unity to 3.4.1 or higher. I had a similar problem, upgrading sorted it out.
Your answer
Follow this Question
Related Questions
Guys please help me!!how to download xml file from url in android device runtime 1 Answer
Unable to stream online video on android 1 Answer
Save an image to PersistentDataPath then access it again 1 Answer
Get file list from a directory on Android 4 Answers
WWW.GetAudioClip hardware decoding? ( on iphone and android ) 1 Answer