Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class MainActivity : AppCompatActivity() {
val TAG = MainActivity::class.java.simpleName
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
val handler = Handler(Looper.getMainLooper())
Log.d(TAG, "Before post delayed:${System.currentTimeMillis()}")
handler.postDelayed(
{
Log.d(TAG, "In post delayed:${System.currentTimeMillis()}")
methodCall()
}, 5000
)
}
private fun methodCall() {
Log.d(TAG, "methodCall():${System.currentTimeMillis()}")
AsyncTask(applicationContext).execute()
val handler = Handler(Looper.getMainLooper())
handler.postDelayed({
Log.d(TAG, "ENTERED")
}, 5000)
}
class AsyncTask(applicationContext: Context) : android.os.AsyncTask<Void, Void, Int>() {
val TAG = AsyncTask::class.java.simpleName
override fun doInBackground(vararg params: Void?): Int? {
Log.d(TAG, "doInBackground()")
return 1234
}
override fun onPostExecute(result: Int?) {
Log.d(TAG, "onPostExecute() 1")
super.onPostExecute(result)
Log.d(TAG, "onPostExecute() 2")
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment