您好,登錄后才能下訂單哦!
在android6.0項目中,因需要做全屏處理,故在此整理出全屏時禁止通知欄下滑的代碼,希望可以幫助到也有如此困惑的人。
1.在onCreate中添加://設置全屏
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
2.在onResume()函數(shù)中添加://進入activity時,設置禁止通知欄不滑
Settings.System.putInt(this.getContentResolver(),
Settings.System.FULL_SCREEN_EXPAND_STATUSBAR, 0);
3.在onPause()函數(shù)中添加://離開activity時,恢復通知欄下滑
Settings.System.putInt(this.getContentResolver(),
Settings.System.FULL_SCREEN_EXPAND_STATUSBAR, 1);
4.在frameworks/base/services/core/java/com/android/server/policy/PhoneWindowManager.javar的updateSystemUiViSiBilityLw()函數(shù)中添加://此代碼我添加在tmpVisibility = updateLightStatusBarLw(tmpVisibility);后,有可能其它人的項目代碼有改動,在需要此代碼的請酌情添加至合適位置。
final int visibility;
if(Settings.System.getInt(mContext.getContentResolver(),
Settings.System.FULL_SCREEN_EXPAND_STATUSBAR, 1) == 0) {
visibility = tmpVisibility;
}else{
visibility = updateSystemBarsLw(win, mLastSystemUiFlags,tmpVisibility);
}
5.在frameworks/base/core/java/android/provider/Settings.java中添加://定義FULL_SCREEN_EXPAND_STATUSBAR
public static final String FULL_SCREEN_EXPAND_STATUSBAR = "full_screen_expand_statusbar";
6.在frameworks/base/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java中添加://與上方onPause()中意義基本相同,未深究
systemSettings.insertSettingLocked(Settings.System.FULL_SCREEN_EXPAND_STATUSBAR, "1",SettingsState.SYSTEM_PACKAGE_NAME);
說明:為保證添加了FULL_SCREEN_EXPAND_STATUSBAR不會給系統(tǒng)其它地方造成影響,上述6處的代碼請完整添加,否則有可能引起未知錯誤!
免責聲明:本站發(fā)布的內容(圖片、視頻和文字)以原創(chuàng)、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關證據(jù),一經查實,將立刻刪除涉嫌侵權內容。