How to get value of <setenv> directly to Java on android

Hi!
I making an android extension and I need to pass some data from haxe to Java on startup.
I was thinking to have in project.xml, but how can I get that value in Java?
Are there any other ways?
Thank you!

project.xml

<setenv name="MY_VALUE" value="123" />

java

String value = "::ENV_MY_VALUE::";
1 Like

Ya, thanks a lot! :slight_smile:

You can also use the same approach with ::DEFINE_MY_VALUE:: or ::SET_MY_VALUE:: if you <haxedef name="MY_VALUE" value="123" /> or you <set name="MY_VALUE" value="123" /> (or for shorthand I like <define name="MY_VALUE" value="123" /> which does both)

That way it does not affect environment variables which may become a conflict depending upon the name of your variables

1 Like

So many options, where can I read about difference between them?
Which way is better in which situation?

Btw, Joshua, I’m working on Google Play Licensing extension and would like to submit it to github (https://github.com/HaxeExtension) when ready.
What is the best way to do that?

2 Likes

Here is the difference:

  • “set” affects the build process
  • “haxedef” affects the Haxe compile process as a define
  • “define” bundles both “set” and “haxedef” together in the same tag
  • “setenv” affects environment variables during the build (which also behaves like “set”)

I just sent an invite to be a member of the HaxeExtension organization, which should allow you to create a new repository there :smiley:

2 Likes