Tôi đang cố tạo nút để tôi có thể ẩn hoặc hiển thị thanh trạng thái trên máy tính bảng của mình.Android: hiển thị/ẩn thanh trạng thái/thanh công suất
Tôi đã đặt trong onCreate
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS);
và trong các nút show:
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags &= ~WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
hide:
WindowManager.LayoutParams attrs = getWindow().getAttributes();
attrs.flags |= WindowManager.LayoutParams.FLAG_FULLSCREEN;
getWindow().setAttributes(attrs);
Bất kỳ gợi ý/Tipps?
// chỉnh sửa
Tôi đã nhìn vào gợi ý này ở đây: http://android.serverbox.ch/?p=306 và thay đổi mã của tôi như thế này:
private void hideStatusBar() throws IOException, InterruptedException {
Process proc = Runtime.getRuntime().exec(new String[]{"su","-c","service call activity 79 s16 com.android.systemui"});
proc.waitFor();
}
private void showStatusBar() throws IOException, InterruptedException {
Process proc = Runtime.getRuntime().exec(new String[]{"am","startservice","-n","com.android.systemui/.SystemUIService"});
proc.waitFor();
}
Vì vậy, nếu tôi bấm vào nút của tôi một phương pháp được gọi là tôi có thể thấy điều gì đó đang xảy ra vì ứng dụng đang chờ một vài giây. Tôi cũng nhìn vào LockCat và thấy rằng một cái gì đó đang xảy ra.
show: http://pastebin.com/CidTRSTi hide: http://pastebin.com/iPS6Kgbp
Ví dụ http://stackoverflow.com/a/35886019/4395114 –