主板:RK 3288
系统:android 6.0
应用路径:package/app/Settings
在android系统中如果隐藏下边的虚拟按键栏之后进入系统设置后是不能返回的,经过查一些资料之后找到了解决的方法。
在SettingsActivity.java中修改源码:
else {
if (!mIsShowingDashboard) {
mDisplaySearch = false;
// UP will be shown only if it is a sub settings
if (mIsShortcut) {
mDisplayHomeAsUpEnabled = isSubSettings;
} else if (isSubSettings) {
mDisplayHomeAsUpEnabled = true;
} else {
mDisplayHomeAsUpEnabled = false;
}
setTitleFromIntent(intent);
Bundle initialArguments = intent.getBundleExtra(EXTRA_SHOW_FRAGMENT_ARGUMENTS);
switchToFragment(initialFragmentName, initialArguments, true, false,
mInitialTitleResId, mInitialTitle, false);
} else {
// No UP affordance if we are displaying the main Dashboard
mDisplayHomeAsUpEnabled = false;
// Show Search affordance
mDisplaySearch = true;
mInitialTitleResId = R.string.dashboard_title;
switchToFragment(DashboardSummary.class.getName(), null, false, false,
mInitialTitleResId, mInitialTitle, false);
}
将红色语句改成true。改完之后重新编译app,之前在网上查询发现7.0的是改完之后就可以实现返回(无测试),但是我的无效果,解决方法如下:
--- a/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java
+++ b/packages/SettingsLib/src/com/android/settingslib/drawer/SettingsDrawerActivity.java
@@ -79,6 +79,7 @@ public class SettingsDrawerActivity extends Activity {
private boolean mShowingMenu;
private UserManager mUserManager;
+ private boolean isTopflag=false;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -134,7 +135,10 @@ public class SettingsDrawerActivity extends Activity {
&& mDrawerAdapter.getCount() != 0) {
openDrawer();
return true;
- }
+ }else if(!isTopflag && item.getItemId() == android.R.id.home){
+ finish();
+ return true;
+ }
return super.onOptionsItemSelected(item);
}
@@ -153,6 +157,7 @@ public class SettingsDrawerActivity extends Activity {
new CategoriesUpdater().execute();
}
final Intent intent = getIntent();
+ isTopflag = isTopLevelTile(intent);
if (intent != null) {
if (intent.hasExtra(EXTRA_SHOW_MENU)) {
if (intent.getBooleanExtra(EXTRA_SHOW_MENU, false)) {