我在Android上使用Andengine。我有兩個類(Main和函數),如下所示。Android上的環境和GetSharedPreferences
主營:
private Context myContext;
.
.
if (functions.Sonido(myContext)) {
mSound.play();
}
功能:
public boolean Sonido(Context C) {
prefs = C.getSharedPreferences(Filename, Context.MODE_PRIVATE);
valor = prefs.getString("Sound", null);
if (valor == "YES") {
return true;
}else{
return false;
}
}
編輯不給任何錯誤,但我得到的運行時錯誤。請協助我解決它們。
告訴我們您的logcat的...... 「我的英語對不起」 嘿嘿沒有problem..try 'if(functions.Sonido(this)){mSound.play(); }' –