is Activity Alive - Android Activity

Android examples for Activity:Activity Status

Description

is Activity Alive

Demo Code


//package com.java2s;
import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;

public class Main {
    public static boolean isAlive(Activity activity) {
        return activity != null
                && !activity.isFinishing()
                && (Build.VERSION.SDK_INT < 17 ? true
                        : !isActivityDestroyed(activity));
    }//  ww w.  j a v  a2  s.  c  o m

    @TargetApi(17)
    private static boolean isActivityDestroyed(Activity activity) {
        return activity.isDestroyed();
    }
}

Related Tutorials