More functions - launch browser/email (android)
Monkey Forums/Monkey Code/More functions - launch browser/email (android)
| ||
Good day to you all, Thanks to some help from therevills and the mobile tutorials page (very useful page) it is possible (from android at least) to send emails and launch a browser to a specific web page on your android phone: code was posted in the thread below originally but so that it doesn't get lost I thought I'd create a new thread specifically for this functionality. Very useful site for phone dev here: http://mobile.tutsplus.com/ From original thread here: http://www.monkeycoder.co.nz/Community/posts.php?topic=556 Import "extras/extras.${TARGET}.${LANG}" Extern #If TARGET="android" Then Function LaunchBrowser:Void(address:String) = "extern.launchBrowser" class extern { static void launchBrowser(String address) { android.net.Uri uriUrl = android.net.Uri.parse(address); android.content.Intent launchBrowserActivity = new android.content.Intent(android.content.Intent.ACTION_VIEW, uriUrl); MonkeyGame.activity.startActivity(launchBrowserActivity); } } (taken directly from other post) Thanks again - I've worked out how to send emails too - that can be done like this: in your "#if TARGET="android" block put this Function LaunchEmail:Void() = "extern.launchEmail" in your class "extern" put this: static void launchEmail() { android.content.Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Hey! You'll love this new game!"); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Hey! Try our my game at www.etc...."); MonkeyGame.activity.startActivity(emailIntent); } |
| ||
Added these to Diddy - thanks :) I expanded the LaunchEmail command to take email address, subject and text as parameters. Also added support for HTML5, Flash and GLFW(Windows). |
| ||
Tested in my game, works but there is a decent pause on resuming my app when I go to play game again while still in my game, kind of like graphics need re uploading to vid mem. |
| ||
works great for me !! thanks one more question: how we sent email without showing standard controls just to aprove it ? |
| ||
Sharing apps using the standard share routine in Android....static void shareApp(String message) { android.content.Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, "This is the text that will be shared.")); MonkeyGame.activity.startActivity(android.content.Intent.createChooser(sharingIntent,"Share using")); } |
| ||
Slightly fixed:static void shareApp(String message) { android.content.Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); sharingIntent.setType("text/html"); sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, message); MonkeyGame.activity.startActivity(android.content.Intent.createChooser(sharingIntent,"Share using")); } One too many brackets, plus the parameter wasnt been used ;) |
| ||
Oops! thanks for correcting that.... |