Hi,

I sometimes use java System.getProperty() & System.setProperty() as an
alternative to environment variables eg -

System.setProperty("DEBUG", debug);

and

if (System.getProperty("DEBUG","0").equals("1")) Log.w("abc", "123");

They seem to be available across activities & threads within the same
process but do your own testing to be sure.

Regards

On Sep 30, 12:29 am, Mark Murphy <[email protected]> wrote:
> On Thu, Sep 29, 2011 at 10:11 AM, [email protected]
>
> <[email protected]> wrote:
> > I agree that environmental variables might not be the best approach,
> > but we are porting software, which is expected to use it.
>
> Then fix the software to not use environment variables.
>
> For example, if this is C/C++ code, as part of your work to modify
> this code to use the NDK and JNI, at worst you can wrap the
> environment variable logic in #ifdefs and replace them with data
> passed into your JNI API for Android. Better yet, implement some
> pluggable strategy for where this data comes from, to give you
> flexibility for whatever front ends you might need.
>
> > So, there is
> > no way for one process/thread to set environmental variables, which
> > can be read by other one?
>
> Environment variables are not part of the Android SDK. There are no
> guidelines for using environment variables on Android for SDK
> applications. Java itself does not have a means of setting environment
> variables.
>
> > What about calling from the java application
> > the .so library library, which sets the variables by calling some
> > Android functions on C level - can I read them then by System.getenv()
> > or by executing some process by Runtime.getRuntime().exec()?
>
> It would be more reliable for you to fix your software that you are
> porting to not use environment variables. For example, there is no
> guarantee that an environment variable set this way would be visible
> to the SDK application, and even if it is visible today, it may not be
> visible in some future Android release.
>
> > Anyway how it is done in general on Android with variables? I can
> > define in the shell, but when I start the application from the shell I
> > cannot access them even I exported them... But in any case I can read
> > the PATH variable, so there must be a way to set the variables...
>
> The firmware is welcome to do whatever it wants.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> Android Training in NYC:http://marakana.com/training/android/

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to