OpenURL not working on Android

Hi. My code below works perfectly in the editor, but on Android, it doesn’t work. I have a debugging plugin so that I can see log errors/warnings/messages on Android too.

This is my code for a very simple button:

IEnumerator FindUrl(WWW www)
{
	yield return www;
	
	// check for errors
	if (www.error == null)
	{
		
		//Assign the data that was fetched to the variable answer
		string answer = www.text.ToString();
		print(answer);

		yield return new WaitForSeconds(10f);

		Application.OpenURL(answer);

		// working		//Application.OpenURL("http://www.estate-maeglerne.dk/maegler/pages/property-presentation/property.action?caseno=470-2614&shopno=220079&utm_campaign=boligsiden&utm_source=boligsiden_dk&utm_medium=exitlinks&csref=boligsiden_website");

	} else {
		Debug.Log("WWW Error: " + www.error);
	}

}

// Update is called once per frame
void Update () {

	if(Input.GetMouseButtonUp(0)) {

		if(transform.guiTexture.HitTest(Input.mousePosition) && transform.name != "") {

			WWW get_www = new WWW("http://danico.dk/Boligapp/Maegler.php?url=" + "http://www.boligsiden.dk/" + "/viderestilling/305d8d3ac029427d8dfc53f4a88b8552"); 
			//Start the Coroutine
			print("http://danico.dk/Boligapp/Maegler.php?url=" + "http://www.boligsiden.dk/" + "/viderestilling/305d8d3ac029427d8dfc53f4a88b8552");
			StartCoroutine(FindUrl(get_www));

		}

	}

The answer string is a URL including http://
It is working perfectly in the Editor.
The browser is not opening on Android.

However, if I change the code to this:
Application.OpenURL(“http://www.estate-maeglerne.dk/maegler/pages/property-presentation/property.action?caseno=470-2614&shopno=220079&utm_campaign=boligsiden&utm_source=boligsiden_dk&utm_medium=exitlinks&csref=boligsiden_website”);

It works on Android, but not when the URL is recieved from WWW.

How can this be fixed? Feel free to add this script to a GUITexture to see it in action.

Hi,

Check the URL in the response. I guess the format of the URL must be incorrect. Check if there is http:// in your response?

I found the solution!

For Android it is important that you add “http://” in WWW.

//Not correct: 
string post_url = "http://www.testdomain.de/display.php";
WWW hs_post = new WWW(post_url);

//correct: 
string post_url = "www.testdomain.de/display.php";
WWW hs_post = new WWW("http://"+post_url);

In my example you must not add the “http://” to the string, because the WWW variable hs_post will cut it. You have to add it at WWW hs_post.

On android go to player settings and change internet access from auto to required. Otherwise it will work on windows but not android.