2014-03-27 60 views
1

我想顯示我的應用程序使用的設備功能信息。例如:像這樣如何在Android中獲取設備功能信息?

android.hardware.location.network 
android.hardware.wifi 
com.google.android.feature.GOOGLE_BUILD 
android.hardware.telephony 
android.hardware.location 
android.software.sip 
android.hardware.touchscreen.multitouch 
glEsVersion = 2.0 

信息,我用下面的代碼:

PackageManager packageManager = mcontex.getApplicationContext().getPackageManager(); 
    FeatureInfo[] feature = packageManager.getSystemAvailableFeatures(); 
    String k = null; 
    for (FeatureInfo s : feature) { 
     k = s.name + "\n" + "glEsVersion =" + s.reqGlEsVersion; 
    } 
    return k; 

它只顯示glEsversion但休息吧表明空。任何建議?

+1

FeatureInfo []的數組和字符串k爲信號變量從陣列 – MilapTank

回答

1

您始終覆蓋ķ,但如果我理解正確的話,你想在一個字符串的所有功能

for (FeatureInfo s : feature) { 
    k =k+ s.name + "\n" + "glEsVersion =" + s.reqGlEsVersion; 
} 
+0

你的答案其只返回最後一個值是正確的。我在代碼中幾乎沒有改變。對於(FeatureInfo S:特徵){ \t \t \t如果(s.name == NULL){ \t \t \t \t s.name = 「」; \t \t \t} \t \t \t k = k + s.name +「\ n」; \t \t \t l =「glEsVersion =」+ s.reqGlEsVersion; \t \t} \t \t z = k + 1; \t \t return z; –