How to set Android environment variables for inheritance application?

I use adb shellto debug the application and set some env variable like this export TESTVAR=test, then I run the application in the same shell am start -n my.app.package, it is strange that the process does not see TESTVAR(check /proc/pid/environ), because the parent of the application process is zygote . How to configure env for such application processes?

+4
source share
1 answer

If you use environment variables for testing purposes and do not have the functionality that will depend on them during production, this answer may be useful. However, if you interact and use JNI libraries and want to use environment variables as a directive for these libraries, then I'm not sure if they are usable.

In API 21, Google introduced the Os class to provide system-level access to developers. I have not tried it yet, but it should be the interface between the Android application and the underlying Linux kernel. Which, I hope, is what you need. There is, of course, the setenv method , which delegates the options you set on Linux setenv .

, , , API 21, , Android .

0

Source: https://habr.com/ru/post/1658902/


All Articles