SDL2 on Android get "Open with" arguments |
SDL2 on Android get "Open with" arguments |
Martin Felis
Guest
|
Hi Noxalus,
you have to use Android Intents for this. In the Android port of the LÖVE engine we can open games by opening a link or a file on the phone. In the AndroidManifest.xml you have to define intent-filters for your activity that take into account the file scheme, mime type etc. It can be a bit tricky to get those right and I am still not yet happy how we do it. You can look at https://bitbucket.org/MartinFelis/love-android-sdl2 which might help you get started. The relevant files are AndroidManifest.xml and src/love2d/android/GameActivity.java. Good luck! Martin On 22.10.2014 10:31, Noxalus wrote:
_______________________________________________ SDL mailing list http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org |
|||||||||||||
|
Noxalus
|
Thanks a lot Martin for you answer!
I just saw that we can effectively get the filename from intent on this post: http://stackoverflow.com/questions/2971871/how-to-get-the-file-name-from-the-intent?answertab=active#tab-top I can do like you, but the best way would be to let SDL manage this instead. For iOS, if we look at the file SDL_uikitappdelegate.m, we can see (line 275) that it uses SDL_SendDropFile function to trigger an SDL_DropEvent with the filename. It should be possible to do the exact same thing updating SDLActivity.java, isn't it ? |
|||||||||||
|
Noxalus
|
Ok, I performed some changes to SDL files and I can now retrieve the filename from SDL_DropEvent like on iOS.
What I changed is very simple. For SDLActivity.java, I added this code at the end of onCreate method (line 99):
Without forget to declare onNativeDropFile among the C functions (line 284):
To finish, I updated the file SDL_android.c (into src/core/android) to add the onNativeDropFile function (line 143):
I would like to suggest a pull request on the SDL repository, but they use Mercurial and I don't know if it's possible... |
|||||||||||||||||
|
SDL2 on Android get "Open with" arguments |
Jonas Kulla
Guest
|
2014-10-22 14:40 GMT+02:00 Noxalus:
You can create a patch and attach it in a bugzilla ticket: https://bugzilla.libsdl.org/enter_bug.cgi?product=SDL Then it will (hopefully) not be forgotten. |
|||||||||||||
|
Noxalus
|
I don't know what you mean by "patch", but I posted the "bug" here: https://bugzilla.libsdl.org/show_bug.cgi?id=2762
I just put the updated files as attachment. Is it the only way to contribute? Github and its pull request system is far more convenient! |
|||||||||||
|
SDL2 on Android get "Open with" arguments |
Jonas Kulla
Guest
|
2014-10-22 15:48 GMT+02:00 Noxalus:
(Suddenly I know how old people feel..) Assuming you cloned the mercurial repo: hg diff > my_fix.patch Then attach 'my_fix.patch' in bugzilla. |
|||||||||||||
|
Noxalus
|
Thanks for your help Jonas, I replaced the former attachment by a real patch.
|
|||||||||||
|