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

The following examples show how to use android.app.Activity#isChangingConfigurations() . 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
Source Project: scene   File: Scene.java    License: Apache License 2.0 6 votes vote down vote up
/** @hide */
@RestrictTo(LIBRARY_GROUP)
public void dispatchDetachActivity() {
    Activity activity = this.mActivity;
    this.mActivity = null;
    this.mSceneContext = null;
    mCalled = false;
    onDetach();
    if (!mCalled) {
        throw new SuperNotCalledException("Scene " + this
                + " did not call through to super.onDetach()");
    }

    if (!activity.isChangingConfigurations()) {
        this.mScope.destroy();
    }
    this.mScope = null;
    // Must be called last, in case someone do add in onDestroy/onDetach
    mPendingActionList.clear();
}
 
Example 2
Source Project: DevUtils   File: DevUtils.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    // 检测当前的 Activity 是否因为 Configuration 的改变被销毁了
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    } else {
        --mForegroundCount;
        if (mForegroundCount <= 0) {
            mIsBackground = true;
            postStatus(false);
        }
    }

    if (DevUtils.sAbstractActivityLifecycle != null) {
        DevUtils.sAbstractActivityLifecycle.onActivityStopped(activity);
    }
}
 
Example 3
@Override public void onActivityStarted(Activity activity) {
  currentActivity = new WeakReference<>(activity);
  // remove any scheduled checks since we're starting another activity
  // we're definitely not going background
  if (check != null) {
    handler.removeCallbacks(check);
  }

  // check if we're becoming foreground and notify listeners
  if (!foreground && (activity != null && !activity.isChangingConfigurations())) {
    foreground = true;
    if (listener != null) {
      listener.onBecameForeground(activity);
    }
  }
}
 
Example 4
@Override
public void onStop() {
    super.onStop();
    final Activity activity = getActivity();
    messageListAdapter.unregisterListenerInAudioPlayer();
    if (activity == null || !activity.isChangingConfigurations()) {
        hideSoftKeyboard(activity);
        messageListAdapter.stopAudioPlayer();
    }
    if (this.conversation != null) {
        final String msg = this.binding.textinput.getText().toString();
        storeNextMessage(msg);
        updateChatState(this.conversation, msg);
        this.activity.xmppConnectionService.getNotificationService().setOpenConversation(null);
    }
    this.reInitRequiredOnStart = true;
}
 
Example 5
Source Project: mosby   File: FragmentMviDelegateImpl.java    License: Apache License 2.0 6 votes vote down vote up
private boolean retainPresenterInstance(boolean keepPresenterOnBackstack, Activity activity,
    Fragment fragment) {

  if (activity.isChangingConfigurations()) {
    if (keepPresenterDuringScreenOrientationChange) {
      return true;
    }
    return false;
  }

  if (activity.isFinishing()) {
    return false;
  }

  if (keepPresenterOnBackstack && BackstackAccessor.isFragmentOnBackStack(fragment)) {
    return true;
  }

  return !fragment.isRemoving();
}
 
Example 6
Source Project: tysq-android   File: Utils.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    } else {
        --mForegroundCount;
        if (mForegroundCount <= 0) {
            mIsBackground = true;
            postStatus(false);
        }
    }
}
 
Example 7
Source Project: LiveEventBus   File: AppUtils.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    } else {
        --mForegroundCount;
        if (mForegroundCount <= 0) {
            mIsBackground = true;
            postStatus(false);
        }
    }
}
 
Example 8
Source Project: LiveEventBus   File: AppUtils.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    } else {
        --mForegroundCount;
        if (mForegroundCount <= 0) {
            mIsBackground = true;
            postStatus(false);
        }
    }
}
 
Example 9
@SuppressLint("NewApi")
@Override
public void onStop()
{		
	Activity fa = getActivity();
	if(fa!=null)
	{
		if(!fa.isChangingConfigurations() || (fa instanceof FileManagerActivity))
			cancelCalcTask();
	}
	super.onStop();
}
 
Example 10
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        mActivityConfigChangesCount--;
    } else {
        mForegroundActivityCount--;
        if (mForegroundActivityCount <= 0) {
            // 前台到后台
            Log.e(TAG, "前台到后台");
        }
    }
}
 
Example 11
@Override public void onActivityPaused(Activity activity) {
  // if we're changing configurations we aren't going background so
  // no need to schedule the check
  if (!activity.isChangingConfigurations()) {
    // don't prevent activity being gc'd
    final WeakReference<Activity> ref = new WeakReference<>(activity);
    handler.postDelayed(check = () -> onActivityClosed(ref.get()), CHECK_DELAY);
  }
}
 
Example 12
/**
 * Method called when the activity was considered close. This method validates if we are till on
 * foreground in case an activity was closed but a new one was opened.
 *
 * @param activity The  activity that was in foreground when this method was triggered.
 */
private void onActivityClosed(Activity activity) {
  if (foreground) {
    if ((activity == currentActivity.get()) && (activity != null
        && !activity.isChangingConfigurations())) {
      foreground = false;
      if (listener != null) {
        listener.onBecameBackground();
      }
    }
  }
}
 
Example 13
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    } else {
        --mForegroundCount;
        if (mForegroundCount <= 0) {
            mIsBackground = true;
            postStatus(activity, false);
        }
    }
    processHideSoftInputOnActivityDestroy(activity, true);
    consumeActivityLifecycleCallbacks(activity, Lifecycle.Event.ON_STOP);
}
 
Example 14
Source Project: AndroidAnimationExercise   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    } else {
        --mForegroundCount;
        if (mForegroundCount <= 0) {
            mIsBackground = true;
            postStatus(false);
        }
    }
}
 
Example 15
Source Project: frenchtoast   File: FrenchToast.java    License: Apache License 2.0 5 votes vote down vote up
@Override public void onActivityDestroyed(Activity activity) {
  Holder holder = createdActivities.remove(activity);
  if (holder.queueOrNull == null) {
    return;
  }
  if (activity.isChangingConfigurations() && holder.savedUniqueId != null) {
    retainedQueues.put(holder.savedUniqueId, holder.queueOrNull);
    // onCreate() is always called from the same message as the previous onDestroy().
    MAIN_HANDLER.post(clearRetainedQueues);
  } else {
    holder.queueOrNull.clear();
  }
}
 
Example 16
@Override public void onActivityStopped(Activity activity) {
  try {
    if (activity.isChangingConfigurations()) {
      activitiesOnRotation.add(activity.getPackageName() + activity.getLocalClassName());
    } else if (activityStack.size() <= 1) {
      appWillEnterBackground();
    }
    removeActivityFromStack(activity);
  } catch (Exception e) {
    AppliverySdk.Logger.log(e.getMessage());
  }
}
 
Example 17
@Override public void onActivityStarted(Activity activity) {

    if (activitiesOnRotation.contains(activity.getPackageName() + activity.getLocalClassName())) {
      activitiesOnRotation.remove(activity.getPackageName() + activity.getLocalClassName());
    } else {
      if (activityStack.empty() && !activity.isChangingConfigurations()) {
        appWillReturnfromBackground();
      }
    }

    this.activityStack.push(new ActivityLifecyleWrapper(activity, true, false));
  }
 
Example 18
Source Project: AndroidUtilCode   File: DebugUtils.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    }
}
 
Example 19
Source Project: mosby   File: ActivityMvpDelegateImpl.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Determines whether or not a Presenter Instance should be kept
 *
 * @param keepPresenterInstance true, if the delegate has enabled keep
 */
static boolean retainPresenterInstance(boolean keepPresenterInstance, Activity activity) {
  return keepPresenterInstance && (activity.isChangingConfigurations()
      || !activity.isFinishing());
}
 
Example 20
Source Project: mosby   File: ActivityMviDelegateImpl.java    License: Apache License 2.0 2 votes vote down vote up
/**
 * Determines whether or not a Presenter Instance should be kept
 *
 * @param keepPresenterInstance true, if the delegate has enabled keep
 */
static boolean retainPresenterInstance(boolean keepPresenterInstance, Activity activity) {
  return keepPresenterInstance && (activity.isChangingConfigurations()
      || !activity.isFinishing());
}