Android Setting增加返回主页按钮

很多安卓的项目,都会隐藏掉SystemUI,但这种情况下如果用到系统的Setting,就没有办法返回主页了

其实Setting里面简单的修改一下就实现效果了,如下:

diff   –git a/src/com/android/settings/SettingsActivity.java b/src/com/android/settings/SettingsActivity.java
index cd33e4a..03c2ce0 100755
—       a/src/com/android/settings/SettingsActivity.java
+++        b/src/com/android/settings/SettingsActivity.java
@@ -304,11 +304,17 @@ public class SettingsActivity extends SettingsDrawerActivity
findViewById(R.id.search_bar).setVisibility(
deviceProvisioned ? View.VISIBLE : View.INVISIBLE);
if(findViewById(R.id.action_bar)!=null)
–        findViewById(R.id.action_bar).setVisibility(View.GONE);
+        //findViewById(R.id.action_bar).setVisibility(View.GONE);
+        {
+        findViewById(R.id.action_bar).setVisibility(View.VISIBLE);
+        setActionBar(findViewById(R.id.action_bar));
+        }}
final Toolbar toolbar = findViewById(R.id.search_action_bar);
FeatureFactory.getFactory(this).getSearchFeatureProvider()
.initSearchToolbar(this, toolbar);
–        setActionBar(toolbar);
+        //setActionBar(toolbar);//sunlei note D:@20210324
// Please forgive me for what I am about to do.

@@ -324,7 +330,8 @@ public class SettingsActivity extends SettingsDrawerActivity
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(deviceProvisioned);
actionBar.setHomeButtonEnabled(deviceProvisioned);
–        actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard);
+        //sunlei note D:@20210324 for show Settting Title,如果为false则不显示标题文字
+        //actionBar.setDisplayShowTitleEnabled(!mIsShowingDashboard);
}
mSwitchBar = findViewById(R.id.switch_bar);
if (mSwitchBar != null) { }