Disabling Android home button for industry application

后端 未结 2 816
失恋的感觉
失恋的感觉 2021-02-09 11:44

I\'m writing an industry application which will be used by traffic wardens to register offences through my program using forms.

The app is using a webview so it is just

相关标签:
2条回答
  • 2021-02-09 12:22
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    
        getWindow().addFlags(  WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    

    }

    @Override
    public void onBackPressed() {
    
       return;
    }
    
    @Override
    public void onAttachedToWindow()
    {  
    
           this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);     
           super.onAttachedToWindow();
    
    }
    
    0 讨论(0)
  • 2021-02-09 12:34

    The idea is that I am able to make the app the default home app so if the user presses the home button it launches my app and does not exit. How can I accomplish that?

    There is a sample Home application in your Android SDK. Mirror its manifest entry, notably putting the HOME category in the activity's <intent-filter>.

    The first time the, er, traffic warden taps HOME after installing your app, a chooser will appear for which home app to run. Checking the checkbox and tapping your app will then mean the HOME button will run your app forevermore.

    Beyond creating a custom home app, though, there is no way to intercept the HOME button except through firmware modifications.

    0 讨论(0)
提交回复
热议问题