Scope of System.setProperty

2020-07-03 04:00发布

What's the scope of System.setProperty in Android?

If I set a property (say System.setProperty("http.keepAlive", "false")), does it affect all apps in the system, the current app, the current task or the current thread only?

Where is this documented?

2条回答
看我几分像从前
2楼-- · 2020-07-03 04:39

Android Activities of the same application, if you don't specify otherwise in the Manifest.xml, will run in a default Process created for the application when it starts.

Each process runs in its own JVM. So the System.setProperty(), based on @mmccomb 's answer, will reach all Activities in the same Application except if you, on pupose, declare Activities to run in different Processes.

See http://developer.android.com/guide/components/processes-and-threads.html

查看更多
Anthone
3楼-- · 2020-07-03 04:51

Java "system" properties do not cross process boundaries, they are held in memory and are tied to a single instance of the virtual machine. Therefore if you set a system property within application it will not be visible to other applications running on the device.

查看更多
登录 后发表回答