Skip to content
This repository has been archived by the owner on Apr 5, 2021. It is now read-only.

Support Android #6

Open
andybarron opened this issue Oct 27, 2016 · 8 comments
Open

Support Android #6

andybarron opened this issue Oct 27, 2016 · 8 comments

Comments

@andybarron
Copy link
Owner

I think trying to use this on Android would activate the unix branch and try to use the XDG spec... which I'm pretty sure that Android doesn't follow. 😱

@PlasmaPower
Copy link

For Android, all the APIs are available through Java of course, and for this they're all in the Context object. I'm not sure if we can access this through Rust, or if there is an equivalent NDK API. Anyway, if this was a key-value store, we'd be using [getSharedPreferences](https://developer.android.com/reference/android/content/Context.html#getSharedPreferences%28java.lang.String, int%29) (returning a SharedPreferences object of course) which is a lot better than alternatives, but for an actual path I think getExternalFilesDir and getExternalCacheDirs would give us the paths we're looking for.

@andybarron
Copy link
Owner Author

I wonder if either of these fields on ANativeActivity in tomaka/android-rs-glue would work? It seems like they're attached to the Activity struct, so not sure how we'd get to them without a handle to an instance...

@PlasmaPower
Copy link

Maybe, there's no cache dir though of course. Also, we've got the problem of getting the Activity as you mentioned, we wouldn't be the ones setting up the app.

@TatriX
Copy link

TatriX commented Oct 9, 2017

Any news on this?

@andybarron
Copy link
Owner Author

Zilch. Hence the "help wanted" label. I have no idea how to do this. 😞

@icefoxen
Copy link

icefoxen commented Oct 9, 2017

https://developer.android.com/guide/topics/data/data-storage.html seems like the place to start

SDL2's filesystem path code does a sort of similar task so I thought it might be helpful, but doesn't look super hopeful: https://hg.libsdl.org/SDL/file/8df7a59b5528/src/filesystem/android/SDL_sysfilesystem.c

https://hg.libsdl.org/SDL/file/8df7a59b5528/docs/README-android.md has some useful information under "loading assets".

Looks like Android has some special functionality for static data in addition to normal filesystem paths, so it's not entirely trivial.

@andybarron
Copy link
Owner Author

Thanks for the resources! I'll look into this when I have time. Need to get my hands on an Android device to test :) (Though I guess the simulator could work)

@icefoxen
Copy link

No problem. If I have to make a PR for this I will and I want these resources somewhere I can find them to. :D

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants