Java tutorial
//package com.java2s; import android.app.Activity; import android.os.Build; public class Main { public static boolean isActivityValid(Activity activity) { if (activity == null) { return false; } else { if (Build.VERSION.SDK_INT >= 17) { return !activity.isFinishing() && !activity.isDestroyed(); } else { return !activity.isFinishing(); } } } }