Java tutorial
//package com.java2s; //License from project: Open Source License import android.app.Activity; import android.support.annotation.NonNull; import android.support.annotation.Nullable; public class Main { private static void post(@Nullable Activity target, @NonNull Runnable runnable) { if (target == null || target.isFinishing()) { return; } target.runOnUiThread(runnable); } }