Android: onLongClick ->longer time?

4k views Asked by At

I'm trying to hide an administrator password window (to access system settings), so that users of my public access app wouldn't even know how to reach the password dialog. I've figured hiding it under one of the buttons with a long-press would do it, but it seems the onLongClick (about 500ms) is still a bit too short. Is there a way to make it longer? Or do you guys have a better idea, how to manage access to system settings (i.e. wifi and stuff) from a kiosk app.

Help much appreciated, I've hit a dead end so far. Thanks!

_ I know one of the options would be to place the app over the lock-screen (with FLAG_SHOW_WHEN_LOCKED) and make a dialog to kill my activity, which would show the lockscreen, unlock it with a nice alphanumeric pin and access the settings. But I don't really like the idea of it, since (once again) my app is intended for public use _

3

There are 3 answers

1
CommonsWare On

Is there a way to make it longer?

No, sorry.

Or do you guys have a better idea, how to manage access to system settings (i.e. wifi and stuff) from a kiosk app.

Use adb shell am to launch the system settings app, with the device attached to a machine with the Android SDK on it.

0
The Tokenizer On

I saw this was asked over a year ago.. But no accepted answers so HEY!!

Instead of using an onLongclicklistener you can use onTouchListener. Have it wait for the user to stop holding a button down before launching another action.

 view.setOnTouchListener(new OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            switch(event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                // Start
                break;
            case MotionEvent.ACTION_UP:
                // End
                break;
            }
            return false;
        }
    });

Or maybe you can even just have it so everytime a button is clicked a timer starts that time the activity. I've done something similar a couple of months ago start activity when certain time is reached. Those are just a couple of thoughts, hope i helped you come up with a solution.

0
Anthony Honciano On

You know, I was thinking the same thing...but then I came across the setOnTouchListener()... You can probably set this on your button or widget, and when the event status action = 1, it can start a timer to however long you want it. And when it reaches that time it will do something.

If you're creative enough, you can create a class to watch if the press has gone longer then certain time intervals, and if the action changes during that time you can fire your method up.

Hope this idea helps you.