Java tutorial
//package com.java2s; //License from project: Apache License import android.app.Activity; public class Main { /** * Checks if a Context is not null and is not finishing and returns true, otherwise false. */ public static boolean isContextValid(Activity context) { if (context != null && !context.isFinishing()) { return true; } return false; } }