修改 /etc/UPower/UPower.conf
IgnoreLid=true
/etc/systemd/logind.conf
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
重啟
修改 /etc/UPower/UPower.conf
IgnoreLid=true
/etc/systemd/logind.conf
HandleLidSwitch=ignore
HandleLidSwitchExternalPower=ignore
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { // Respond to the action bar's Up/Home button case android.R.id.home: super.onBackPressed(); return true; } return super.onOptionsItemSelected(item); }cited from Stack Overflow
//取得SharedPreference設定("Preference"為設定檔的名稱) SharedPreferences settings = getSharedPreferences("Preference", 0); //置入name屬性的字串 settings.edit().putString("name", nameEditText.getText().toString()).commit();
//取得SharedPreference設定("Preference"為設定檔的名稱) SharedPreferences settings = getSharedPreferences("Preference", 0); //取出name屬性的字串 String name = settings.getString("name", "");需要注意的是,SharePreference必須在每次使用時設定,否則會出現Exception 轉載自cooking-java