我从网上找的几个程序都使用了这个类,可是我用的sdk1.6里没有这个类,怎么回事??

解决方案 »

  1.   

    我要用SystemProperties.get()和SystemProperties.set()方法,大侠救命啊
      

  2.   

    没有android.os.system这个类~~
    SystemProperties是Java语言的类~~~ import java.lang.system 应该就可以了~~
    这个类有没有权限限制我不太清楚~~你可以查查看
      

  3.   

    这是java的类,用于获得系统信息的,直接用就可以啊,如果出错,除非是调用语句错了,应该看下API
      

  4.   

    hoho,说错咯,是有这个类的,在framework\base\core\java下……
      

  5.   

    \Android源代码\android-1.6_r1-donut-src\android\os在这个里面的确是有的我把它的源代码发给你吧
    /*
     * Copyright (C) 2006 The Android Open Source Project
     *
     * Licensed under the Apache License, Version 2.0 (the "License");
     * you may not use this file except in compliance with the License.
     * You may obtain a copy of the License at
     *
     *      http://www.apache.org/licenses/LICENSE-2.0
     *
     * Unless required by applicable law or agreed to in writing, software
     * distributed under the License is distributed on an "AS IS" BASIS,
     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     * See the License for the specific language governing permissions and
     * limitations under the License.
     */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
    {
        public static final int PROP_NAME_MAX = 31;
        public static final int PROP_VALUE_MAX = 91;    private static native String native_get(String key);
        private static native String native_get(String key, String def);
        private static native void native_set(String key, String def);    /**
         * Get the value for the given key.
         * @return an empty string if the key isn't found
         * @throws IllegalArgumentException if the key exceeds 32 characters
         */
        public static String get(String key) {
            if (key.length() > PROP_NAME_MAX) {
                throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
            }
            return native_get(key);
        }    /**
         * Get the value for the given key.
         * @return if the key isn't found, return def if it isn't null, or an empty string otherwise
         * @throws IllegalArgumentException if the key exceeds 32 characters
         */
        public static String get(String key, String def) {
            if (key.length() > PROP_NAME_MAX) {
                throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
            }
            return native_get(key, def);
        }    /**
         * Get the value for the given key, and return as an integer.
         * @param key the key to lookup
         * @param def a default value to return
         * @return the key parsed as an integer, or def if the key isn't found or
         *         cannot be parsed
         * @throws IllegalArgumentException if the key exceeds 32 characters
         */
        public static int getInt(String key, int def) {
            try {
                return Integer.parseInt(get(key));
            } catch (NumberFormatException e) {
                return def;
            }
        }    /**
         * Get the value for the given key, and return as a long.
         * @param key the key to lookup
         * @param def a default value to return
         * @return the key parsed as a long, or def if the key isn't found or
         *         cannot be parsed
         * @throws IllegalArgumentException if the key exceeds 32 characters
         */
        public static long getLong(String key, long def) {
            try {
                return Long.parseLong(get(key));
            } catch (NumberFormatException e) {
                return def;
            }
        }    /**
         * Get the value for the given key, returned as a boolean.
         * Values 'n', 'no', '0', 'false' or 'off' are considered false.
         * Values 'y', 'yes', '1', 'true' or 'on' are considered true.
         * (case insensitive).
         * If the key does not exist, or has any other value, then the default
         * result is returned.
         * @param key the key to lookup
         * @param def a default value to return
         * @return the key parsed as a boolean, or def if the key isn't found or is
         *         not able to be parsed as a boolean.
         * @throws IllegalArgumentException if the key exceeds 32 characters
         */
        public static boolean getBoolean(String key, boolean def) {
            String value = get(key);
            // Deal with these quick cases first: not found, 0 and 1
            if (value.equals("")) {
                return def;
            } else if (value.equals("0")) {
                return false;
            } else if (value.equals("1")) {
                return true;
            // now for slower (and hopefully less common) cases
            } else if (value.equalsIgnoreCase("n") ||
                       value.equalsIgnoreCase("no") ||
                       value.equalsIgnoreCase("false") ||
                       value.equalsIgnoreCase("off")) {
                return false;
            } else if (value.equalsIgnoreCase("y") ||
                       value.equalsIgnoreCase("yes") ||
                       value.equalsIgnoreCase("true") ||
                       value.equalsIgnoreCase("on")) {
                return true;
            }
            return def;
        }    /**
         * Set the value for the given key.
         * @throws IllegalArgumentException if the key exceeds 32 characters
         * @throws IllegalArgumentException if the value exceeds 92 characters
         */
        public static void set(String key, String val) {
            if (key.length() > PROP_NAME_MAX) {
                throw new IllegalArgumentException("key.length > " + PROP_NAME_MAX);
            }
            if (val != null && val.length() > PROP_VALUE_MAX) {
                throw new IllegalArgumentException("val.length > " +
                    PROP_VALUE_MAX);
            }
            native_set(key, val);
        }
    }
      

  6.   

    问题已解决,现分享给大家:
    把Android SDK 目录下data下的layoutlib.jar文件加到当前工程的附加库路径中,然后在源程序中Import 相应的包即可
    如import android.os.SystemProperties;
      

  7.   

    你没有导入 import android.os.SystemProperties; 吧,使用ctrl+shift+o自动补全就行了
      

  8.   

    应该说得很清楚了吧. 例如:...\android-windows\platforms\android-2.1\data\layoutlib.jar
      

  9.   

    另外为什么这样就能使用了呢,仍然有@Hide阿
      

  10.   

    LZ的方式不可取,因为layoutlib.jar 相对来说比较大了,如果单单用SystemProperties类的,可以直接把源码拷出来。
      

  11.   

    我也碰到这个问题了。按照LZ的方法解决了。THKS