disable all home button and task bar features on Nexus 7

前端 未结 3 1021
名媛妹妹
名媛妹妹 2020-12-10 09:35

I am building an app that will form part of an exhibition. It will be displayed on a Nexus 7 which will be securely mounted. The app has touchscreen functionality and will d

3条回答
  •  囚心锁ツ
    2020-12-10 10:07

    Further to the above, which all worked great, and to make sure a comprehensive answer is out there.....

    AFAIK, there is no way of overriding the recent apps button.

    I got around this by change onPause app behavior to start an alarmmanager. There may be a more elegant solution, but this works.

    First, create repeating alarmmanager setupAlarm(seconds)( full details here and here, note I used repeating alarm rather than one off, think both will work though) that starts your activity

    then change onPause to set a 2 second alarm, so whenever someone selects the recent apps button on the nav bar, a 2 second 'alarm' to start mainActivity is set.

    @Override
    public void onPause() {
        setupAlarm(2);
        finish(); //optional
        super.onPause();
    
    }
    

    So with this and the above, any attempt to use the navigation buttons or restart the app results in app starting. So until I get round to investigating the 'kiosk' style roms this is a very good compromise.

提交回复
热议问题