Android – can’t import android.os.SystemProperties in Camera app

android

In camera.java, I need to get property in system. However, I can't import android.os.SystemProperties, compile camera always complains:

packages/apps/Camera/src/com/android/camera/Camera.java:53: cannot find symbol
symbol  : class SystemProperties
location: package android.os
import android.os.SystemProperties;

In the beginning of camera.java, I included:

import android.os.Message;
import android.os.MessageQueue;
import android.os.SystemClock;
import android.os.SystemProperties; /* (this is in line 53)*/

It seems SystemProperties is not in android.os package, but I have checked the frameworks source code, it's indeed in it.

This happen in camera app. I found many apps under packages/app dir using SystemProperties in this manner. It's really strange.

Best Answer

SystemProperties class is setted 'hide' annotation.
So you want to use this class in application layer, you have to use refelection.

the definition of SystemProperties class is below.

package android.os;
/**
 * Gives access to the system properties store.  The system properties
 * store contains a list of string key-value pairs.
 *
 * {@hide}
 */
public class SystemProperties
Related Topic