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();\r
+ net = new AndroidNet(this);\r
this.listener = listener;\r
this.handler = new Handler();\r
\r
\r
package com.badlogic.gdx.backends.android;\r
\r
+import android.content.Intent;\r
+\r
import com.badlogic.gdx.Net;\r
import com.badlogic.gdx.Net.HttpResult;\r
import com.badlogic.gdx.Net.Protocol;\r
\r
// IMPORTANT: The Gdx.net classes are a currently duplicated for LWJGL + Android!\r
// If you make changes here, make changes in the other backend as well.\r
-\r
+ final AndroidApplication app;\r
+ \r
+ public AndroidNet(AndroidApplication activity) {\r
+ app = activity;\r
+ }\r
+ \r
@Override\r
public HttpResult httpGet (String url, String... parameters) {\r
throw new UnsupportedOperationException("Not implemented");\r
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {\r
return new AndroidSocket(protocol, host, port, hints);\r
}\r
+ \r
+ @Override\r
+ public void openURI(String URI) {\r
+ app.startActivity(new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(URI)));\r
+ }\r
}\r
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
* See the License for the specific language governing permissions and\r
* limitations under the License.\r
- ******************************************************************************/
+ ******************************************************************************/\r
package com.badlogic.gdx.backends.ios;\r
\r
import cli.MonoTouch.Foundation.NSDictionary;\r
this.graphics = new IOSGraphics(getBounds(uiViewController), this, input);\r
this.files = new IOSFiles();\r
this.audio = new IOSAudio();\r
+ this.net = new IOSNet(this);\r
\r
Gdx.files = this.files;\r
Gdx.graphics = this.graphics;\r
Gdx.audio = this.audio;\r
Gdx.input = this.input;\r
+ Gdx.net = this.net;\r
\r
this.input.setupPeripherals();\r
\r
******************************************************************************/\r
package com.badlogic.gdx.backends.ios;\r
\r
+import cli.MonoTouch.Foundation.NSUrl;\r
+import cli.MonoTouch.UIKit.UIApplication;\r
+\r
import com.badlogic.gdx.Net;\r
import com.badlogic.gdx.Net.HttpResult;\r
import com.badlogic.gdx.Net.Protocol;\r
\r
public class IOSNet implements Net {\r
\r
+ final UIApplication uiApp;\r
+ \r
+ public IOSNet(IOSApplication app) {\r
+ uiApp = app.uiApp;\r
+ }\r
+ \r
@Override\r
public HttpResult httpGet (String url, String... parameters) {\r
throw new UnsupportedOperationException("Not implemented");\r
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {\r
return new IOSSocket(protocol, host, port, hints);\r
}\r
+ \r
+ @Override\r
+ public void openURI(String URI) {\r
+ uiApp.OpenUrl(new NSUrl(URI));\r
+ }\r
}\r
\r
package com.badlogic.gdx.backends.lwjgl;\r
\r
+import java.awt.Desktop;\r
+import java.net.URI;\r
+\r
import com.badlogic.gdx.Net;\r
import com.badlogic.gdx.net.ServerSocket;\r
import com.badlogic.gdx.net.ServerSocketHints;\r
import com.badlogic.gdx.net.Socket;\r
import com.badlogic.gdx.net.SocketHints;\r
+import com.badlogic.gdx.utils.GdxRuntimeException;\r
\r
public class LwjglNet implements Net {\r
\r
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {\r
return new LwjglSocket(protocol, host, port, hints);\r
}\r
+ \r
+ @Override\r
+ public void openURI(String URI) {\r
+ if (!Desktop.isDesktopSupported()) \r
+ return;\r
+ \r
+ Desktop desktop = Desktop.getDesktop();\r
+ \r
+ if (!desktop.isSupported(Desktop.Action.BROWSE))\r
+ return;\r
+ \r
+ try {\r
+ desktop.browse(new java.net.URI(URI));\r
+ } catch (Exception e) {\r
+ throw new GdxRuntimeException(e);\r
+ }\r
+ }\r
}\r
import com.badlogic.gdx.net.ServerSocketHints;\r
import com.badlogic.gdx.net.Socket;\r
import com.badlogic.gdx.net.SocketHints;\r
+import com.google.gwt.user.client.Window;\r
\r
public class GwtNet implements Net {\r
@Override\r
public Socket newClientSocket (Protocol protocol, String host, int port, SocketHints hints) {\r
throw new UnsupportedOperationException("Not implemented");\r
}\r
+ \r
+ @Override\r
+ public void openURI(String URI) {\r
+ Window.open(URI, "_blank", null);\r
+ }\r
}\r
* @return GdxRuntimeException in case the socket couldn't be opened\r
*/\r
public Socket newClientSocket(Protocol protocol, String host, int port, SocketHints hints);\r
+ \r
+ /**\r
+ * Launches the default browser to display a URI. If the default browser is not able\r
+ * to handle the specified URI, the application registered for handling URIs of the\r
+ * specified type is invoked. The application is determined from the protocol\r
+ * and path of the URI.\r
+ * \r
+ * @param URI the URI to be opened.\r
+ */\r
+ public void openURI(String URI);\r
}\r