如何使用Java读取Android属性 [英] How to read Android properties with Java

查看:189
本文介绍了如何使用Java读取Android属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在终端中使用'adb shell getprop'。
我可以在Android JAVA中使用哪些界面来获取相同的信息?

I use 'adb shell getprop' in the terminal. What interfaces can I use in Android JAVA to get the same information?

我尝试了几样的事情:

Properties sysProps = System.getProperties();

但我不认为这些是我想要的相同属性?具体来说,我想找到类似于以下内容的值:

But I don't think these are the same properties I am looking for? Specifically, I want to find values that will return similar to the following:

adb shell getprop | grep dolby

shell'grep dolby'命令返回:

The shell 'grep dolby' command returns this:

[audio.dolby.ds2.enabled]: [true] 
[dolby.audio.sink.info]: [headset] 
[dolby.ds.dialogenhancer.state]: [on] 
[dolby.ds.graphiceq.state]: [off] 
[dolby.ds.hpvirtualizer.state]: [off] 
[dolby.ds.intelligenteq.preset]: [Off] 
[dolby.ds.intelligenteq.state]: [off] 
[dolby.ds.platform]: [qcom] 
[dolby.ds.profile.name]: [Movie] 
[dolby.ds.spkvirtualizer.state]: [off] 
[dolby.ds.state]: [off] 
[dolby.ds.volumeleveler.state]: [on] 

但我想在Android JAVA中访问此信息码。

But I want to access this information in Android JAVA code.

任何想法?

推荐答案

System.getProperties() not 返回与getprop相同的属性。

System.getProperties() does not return the same properties as getprop.

要获取getprop属性,请尝试使用Runtime.exec()执行getprop并读取其标准输出。

To get getprop properties, try executing getprop using Runtime.exec() and reading its standard output.

这篇关于如何使用Java读取Android属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆