OSDN Git Service

openURI in android backend now uses runOnUIThread
authormoly <0700689@live.abertay.ac.uk>
Wed, 10 Oct 2012 15:24:48 +0000 (16:24 +0100)
committermoly <0700689@live.abertay.ac.uk>
Wed, 10 Oct 2012 15:24:48 +0000 (16:24 +0100)
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidApplication.java
backends/gdx-backend-android/src/com/badlogic/gdx/backends/android/AndroidNet.java

index b3b55e0..58826e7 100644 (file)
@@ -173,6 +173,7 @@ public class AndroidApplication extends Activity implements Application {
                input = new AndroidInput(this, graphics.view, config);\r
                audio = new AndroidAudio(this, config);\r
                files = new AndroidFiles(this.getAssets(), this.getFilesDir().getAbsolutePath());\r
+               net = new AndroidNet(this);\r
                this.listener = listener;\r
                this.handler = new Handler();\r
 \r
@@ -181,6 +182,7 @@ public class AndroidApplication extends Activity implements Application {
                Gdx.audio = this.getAudio();\r
                Gdx.files = this.getFiles();\r
                Gdx.graphics = this.getGraphics();\r
+               Gdx.net = this.getNet();\r
 \r
                createWakeLock(config);\r
                return graphics.getView();\r
@@ -221,6 +223,7 @@ public class AndroidApplication extends Activity implements Application {
                Gdx.audio = this.getAudio();\r
                Gdx.files = this.getFiles();\r
                Gdx.graphics = this.getGraphics();\r
+               Gdx.net = this.getNet();\r
 \r
                ((AndroidInput)getInput()).registerSensorListeners();\r
 \r
index 4215741..2d25844 100755 (executable)
@@ -17,6 +17,7 @@
 package com.badlogic.gdx.backends.android;\r
 \r
 import android.content.Intent;\r
+import android.net.Uri;\r
 \r
 import com.badlogic.gdx.Net;\r
 import com.badlogic.gdx.Net.HttpResult;\r
@@ -58,6 +59,12 @@ public class AndroidNet implements Net {
        \r
        @Override\r
        public void openURI(String URI) {\r
-               app.startActivity(new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(URI)));\r
+               final Uri uri = Uri.parse(URI);\r
+               app.runOnUiThread(new Runnable(){\r
+                       @Override\r
+                       public void run () {\r
+                               app.startActivity(new Intent(Intent.ACTION_VIEW, uri));\r
+                       }\r
+               });\r
        }\r
 }\r