【问题标题】:Is it possible to lock status bar and navigation bar on Android M是否可以在 Android M 上锁定状态栏和导航栏
【发布时间】:2017-04-25 19:13:21
【问题描述】:

在我的项目中,我需要锁定状态栏和导航栏以避免最终用户进入原始启动器,并且在 API 21 中我尝试使用 startLocktask() 方法,这两个栏功能都可以禁用,但我无法调用第三方APK,那么,如果有机会锁定两个栏,但仍然可以启动第三方APK?

【问题讨论】:

  • 我猜你说的是 kiosk mode api,它只适用于你的应用程序。所以简短的回答:不,您的应用无法确定第三方应用的状态和导航栏的行为。

标签: java android


【解决方案1】:

我很久以前就发现了这个,也许对你也有用:

public class MainActivity extends AppCompatActivity {


@Override
protected void onCreate (Bundle savedInstanceState) {

    super.onCreate (savedInstanceState);

    getWindow().getDecorView().setSystemUiVisibility (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

    // Hide the Status Bar
    getWindow ().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);


    setContentView (R.layout.main_layout);

}

@Override
protected void onResume () {
    //Log.d (TAG, "onResume");
    super.onResume ();

    getWindow().getDecorView().setSystemUiVisibility (View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);

    // Hide the Status Bar
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

}

}

当屏幕旋转时要小心,你也应该记住它。

希望对你有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-14
    • 1970-01-01
    相关资源
    最近更新 更多