Custom timeout for a method - Android -


in android app, i'm using method tries user's current location in custom java class. set timeout that, when expires, can whatever want. want timeout cancelable.

how can in simple way?

thanks

you can in many ways

timertask

countdowntimer

thread.sleep() (on background thread, please)

runnable

you have many options, depends on how want implement , need. there many examples , tutorials each on google , so.

countdowntimer sounds pretty because can set time in millis , want in onfinish() work.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -