2

Android ストック ROM と SenseUI などの他の ROM を区別する必要があるアプリを作成しています。

アプリケーション内でそれを行うにはどうすればよいですか?

ありがとう。

4

1 に答える 1

2

ro.product.brandを使用してクエリを実行getpropすると、必要なものが正確に得られることがわかりました。

/**
 * Returns the ROM manufacturer.
 *
 * @return The ROM manufacturer, or NULL if not found.
 */
public static String getROMManufacturer() {
    String line;
    BufferedReader input = null;
    try {
        Process p = Runtime.getRuntime().exec("getprop ro.product.brand");
        input = new BufferedReader(new InputStreamReader(p.getInputStream()), 1024);
        line = input.readLine();
        input.close();
    }
    catch (IOException ex) {
        Log.e(TAG, "Unable to read sysprop ro.product.brand", ex);
        return null;
    }
    finally {
        if (input != null) {
            try {
                input.close();
            }
            catch (IOException e) {
                Log.e(TAG, "Exception while closing InputStream", e);
            }
        }
    }
    return line;
}

ストック ROM の場合、返される値はgoogle
です。たとえば、SenseUI の場合、HTCが返されます。

上記のメソッドは、GoogleまたはHTCなどのみを返します...

それが他の誰かにも役立ったことを願っています。

于 2013-12-25T12:24:43.950 に答える