Java Code Examples for android.app.Activity#equals()

The following examples show how to use android.app.Activity#equals() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * Removes a given activity from the activity stack
 * 
 * @param activity the activity to remove
 */

private void removeActivityFromStack(Activity activity){

	Iterator<WeakReference<Activity>> activityStackIterator = activityStack.iterator();
	while(activityStackIterator.hasNext()){
		Activity activityFromWeakReference = activityStackIterator.next().get();

		if(activityFromWeakReference == null){
			activityStackIterator.remove();
		}

		if(activity != null && activityFromWeakReference != null && activityFromWeakReference.equals(activity)){
			activityStackIterator.remove();
		}
	}
}
 
Example 2
Source Project: AndroidUtilCode   File: ActivityUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Finish to the activity.
 *
 * @param activity      The activity.
 * @param isIncludeSelf True to include the activity, false otherwise.
 * @param isLoadAnim    True to use animation for the outgoing activity, false otherwise.
 */
public static boolean finishToActivity(@NonNull final Activity activity,
                                       final boolean isIncludeSelf,
                                       final boolean isLoadAnim) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity act : activities) {
        if (act.equals(activity)) {
            if (isIncludeSelf) {
                finishActivity(act, isLoadAnim);
            }
            return true;
        }
        finishActivity(act, isLoadAnim);
    }
    return false;
}
 
Example 3
Source Project: AndroidUtilCode   File: ActivityUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Finish to the activity.
 *
 * @param activity      The activity.
 * @param isIncludeSelf True to include the activity, false otherwise.
 * @param enterAnim     A resource ID of the animation resource to use for the
 *                      incoming activity.
 * @param exitAnim      A resource ID of the animation resource to use for the
 *                      outgoing activity.
 */
public static boolean finishToActivity(@NonNull final Activity activity,
                                       final boolean isIncludeSelf,
                                       @AnimRes final int enterAnim,
                                       @AnimRes final int exitAnim) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity act : activities) {
        if (act.equals(activity)) {
            if (isIncludeSelf) {
                finishActivity(act, enterAnim, exitAnim);
            }
            return true;
        }
        finishActivity(act, enterAnim, exitAnim);
    }
    return false;
}
 
Example 4
/**
 * 删除栈上该activity之上的所有activity
 */
public void finishAfterActivity(Activity activity){
    if (activity!=null && mStack.search(activity) == -1){
        L.e("在栈中找不到该activity", ActivityManager.class);
        return;
    }
    while (mStack.peek() != null){
        Activity temp = mStack.pop();
        if (temp!=null && temp.equals(activity)){
            mStack.push(temp);
            break;
        }
        if (temp!=null)
            temp.finish();
    }
}
 
Example 5
@Override
public void onActivityDestroyed(Activity activity) {
    if (sCurrentActivity == null || activity.equals(sCurrentActivity)) {
        if (sBluetoothServerService != null) {
            sBluetoothServerService.stop();
        }
        if (sBluetoothClientService != null) {
            sBluetoothClientService.stop();
        }
        if (sOrientationProvider != null) {
            sOrientationProvider.stop();
        }

        restoreBluetoothDeviceName();
    }
}
 
Example 6
Source Project: SocialSdkLibrary   File: _SocialSdk.java    License: Apache License 2.0 5 votes vote down vote up
WeakReference<Activity> find(Activity activity) {
    Activity weakAct;
    for (WeakReference<Activity> activityWeakReference : mActivityList) {
        weakAct = activityWeakReference.get();
        if (weakAct != null && weakAct.equals(activity)) {
            return activityWeakReference;
        }
    }
    return null;
}
 
Example 7
Source Project: Simpler   File: App.java    License: Apache License 2.0 5 votes vote down vote up
private Activity findActivity(Activity activity) {
    if (null == activity || null == mActivityList) {
        return null;
    }
    for (Activity aty : mActivityList) {
        if (null == aty) {
            continue;
        }
        if (activity.equals(aty)) {
            return aty;
        }
    }
    return null;
}
 
Example 8
Source Project: AndroidUtilCode   File: ActivityUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Return whether the activity exists in activity's stack.
 *
 * @param activity The activity.
 * @return {@code true}: yes<br>{@code false}: no
 */
public static boolean isActivityExistsInStack(@NonNull final Activity activity) {
    List<Activity> activities = UtilsBridge.getActivityList();
    for (Activity aActivity : activities) {
        if (aActivity.equals(activity)) {
            return true;
        }
    }
    return false;
}
 
Example 9
Source Project: DialogUtil   File: ActivityStackManager.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 在基类activity 的 onDetachToWindow时调用
 * @param activity
 */
public void removeTopAttached(Activity activity){
    if(activity ==null){
        return;
    }
    if(topAttachedActivityWeakRef!=null){
        Activity activity1 =  topAttachedActivityWeakRef.get();
        if(activity.equals(activity1)){
            topAttachedActivityWeakRef = null;
        }

    }
}
 
Example 10
Source Project: Cangol-appcore   File: CoreApplication.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 添加一个activity到管理列表里
 *
 * @param activity
 */
public final  void addActivityToManager(Activity activity) {
    boolean contain=false;
    for (final SoftReference<Activity> activityReference : getActivityManager()) {
        if (activityReference != null && activity.equals(activityReference.get())) {
            contain=true;
        }
    }
    if(!contain)
        getActivityManager().add(new SoftReference<Activity>(activity));
}
 
Example 11
Source Project: science-journal   File: AppSingleton.java    License: Apache License 2.0 4 votes vote down vote up
public void setNoLongerResumedActivity(Activity activity) {
  if (activity.equals(resumedActivity.getValue().orNull())) {
    resumedActivity.onNext(Optional.absent());
  }
}
 
Example 12
Source Project: unity-ads-android   File: Intent.java    License: Apache License 2.0 4 votes vote down vote up
public static void removeActiveActivity (Activity activity) {
	if (_activeActivity != null && _activeActivity.get() != null && activity != null && activity.equals(_activeActivity.get())) {
		_activeActivity = null;
	}
}
 
Example 13
public static void clearActivity(Activity activity) {
    if (activity.equals(sCurrentActivity)) {
        sCurrentActivity = null;
    }
}
 
Example 14
private void clearReferences(){
	Activity currActivity = TinyGSN.getCurrentActivity();
	if (currActivity != null && currActivity.equals(this))
		TinyGSN.setCurrentActivity(null);
}
 
Example 15
private void clearReferences(){
	Activity currActivity = TinyGSN.getCurrentActivity();
	if (currActivity != null && currActivity.equals(this))
		TinyGSN.setCurrentActivity(null);
}