Search code examples
androidandroid-appwidget

Android App Widget


I just wanna ask regarding android widget. I'm done creating the app widget to my application and I am asking if android widget has a way of delaying right after clicking/tapping the button. It is like after clicking or tapping the button if there is a notice that will appear if it has been tapped too much wait for 10 seconds. thanks for the reply in advance.


Solution

  • You can store when the next valid click is in a member variable

    // create a static to store valid click time
    private static long nextValidTime = new Date().getTime();
    
        // ... snip ...
    
        // inside your onClick listener
        if (nextValidTime >= Date().getTime()) {
            nextValidTime = new Date().getTime() + 10;
            // doSomething
        } else {
            // show dialogue that click was too soon   
        }