1

Is there a mechanism for observing changes in system properties from your own app in Android SDK?

For example, I want to be able to detect changes in the system.adb.tcp.port property.

szx
  • 6,433
  • 6
  • 46
  • 67

3 Answers3

2

As of API 25 there's no public API for this. You need to dig down into internal functions that only exist to exercise the system.

See __system_property_wait_any() in sys/_system_properties.h. The need to define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_ shows that its use is even discouraged internally.

I wouldn't use this in an app. A quick grep of AOSP indicates that it's only used in test code, so there doesn't appear to be a "friendly" API that makes use of it.

I think you're stuck with polling System.getProperty().

fadden
  • 51,356
  • 5
  • 116
  • 166
1

I don't think exist a mechanism to do this., but you may be able to retrieve system properties by executing getprop in a Process and retrieve its output.

or try this link : [for System.getProperty()] http://developer.android.com/reference/java/lang/System.html#getProperty%28java.lang.String,%20java.lang.String%29

sharan
  • 226
  • 1
  • 4
  • 12
1

For C/C++, please call WaitForProperty defined in "android-base/properties.h" and libbase.

For Java, please call OnPropertyChangedCallback in class Observable.

Mr. Two
  • 11
  • 1