Block all means to close an android application

后端 未结 5 526
盖世英雄少女心
盖世英雄少女心 2020-12-29 10:38

I\'m trying to develop an application for an android tablet.

This tablet will be shown to the public and they can touch it.

I want to block all means to clos

5条回答
  •  渐次进展
    2020-12-29 11:06

    At first you need to add your application as home from your manifest

    
                
                    
                    
                    
                    
                    
    
                
       
    

    after add flag

    getWindow().addFlags(WindowManager.LayoutParams.TYPE_SYSTEM_OVERLAY); //(dont forget to add flag before `setContentView`)
    

    Disable device lock

      private void disableLock() {
    
            KeyguardManager keyguardManager = (KeyguardManager) getSystemService(MainActivity.KEYGUARD_SERVICE);
            KeyguardManager.KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
            lock.disableKeyguard();
        }
    

    Disable home Long click

     @Override
        protected void onUserLeaveHint() {
            startActivity(new Intent(MainActivity.this,MainActivity.class));
            finish();
            super.onUserLeaveHint();
        }
    

    After run you need to set your app to home application !!!

提交回复
热议问题