Android examples for Activity:Activity Status
wait For Activity With Timeout
//package com.java2s; import android.app.Activity; public class Main { public static void waitForActivityWithTimeout(Activity activity, long timeout) { final long endTime = System.currentTimeMillis() + timeout; do {// www . j av a2 s . c o m try { if (activity.isFinishing()) { return; } } catch (Exception e) { // noop } } while (System.currentTimeMillis() < endTime); throw new RuntimeException("Maximum wait elapsed (" + timeout + ") while waiting for activity to finish"); } }