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

The following examples show how to use android.app.Activity#isChangingConfigurations() . 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 File: Scene.java    From scene with 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 File: DevUtils.java    From DevUtils with 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
Source File: FragmentMviDelegateImpl.java    From mosby with 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 4
Source File: ConversationFragment.java    From Conversations with GNU General Public License v3.0 6 votes vote down vote up
@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 File: LifeCycleListener.java    From asf-sdk with GNU General Public License v3.0 6 votes vote down vote up
@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 6
Source File: Utils.java    From tysq-android with 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 File: AppliveryActivityLifecycleCallbacks.java    From applivery-android-sdk with Apache License 2.0 5 votes vote down vote up
@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 8
Source File: AppliveryActivityLifecycleCallbacks.java    From applivery-android-sdk with Apache License 2.0 5 votes vote down vote up
@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 9
Source File: FrenchToast.java    From frenchtoast with 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 10
Source File: Utils.java    From AndroidAnimationExercise with 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 11
Source File: UtilsActivityLifecycleImpl.java    From AndroidUtilCode with 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(activity, false);
        }
    }
    processHideSoftInputOnActivityDestroy(activity, true);
    consumeActivityLifecycleCallbacks(activity, Lifecycle.Event.ON_STOP);
}
 
Example 12
Source File: LifeCycleListener.java    From asf-sdk with GNU General Public License v3.0 5 votes vote down vote up
/**
 * 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
Source File: LifeCycleListener.java    From asf-sdk with GNU General Public License v3.0 5 votes vote down vote up
@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 14
Source File: CrazyDailyActivityLifecycleCallbacks.java    From CrazyDaily with Apache License 2.0 5 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        mActivityConfigChangesCount--;
    } else {
        mForegroundActivityCount--;
        if (mForegroundActivityCount <= 0) {
            // 前台到后台
            Log.e(TAG, "前台到后台");
        }
    }
}
 
Example 15
Source File: FilePropertiesFragment.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
@SuppressLint("NewApi")
@Override
public void onStop()
{		
	Activity fa = getActivity();
	if(fa!=null)
	{
		if(!fa.isChangingConfigurations() || (fa instanceof FileManagerActivity))
			cancelCalcTask();
	}
	super.onStop();
}
 
Example 16
Source File: AppUtils.java    From LiveEventBus with 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 17
Source File: AppUtils.java    From LiveEventBus with 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 18
Source File: DebugUtils.java    From AndroidUtilCode with Apache License 2.0 4 votes vote down vote up
@Override
public void onActivityStopped(Activity activity) {
    if (activity.isChangingConfigurations()) {
        --mConfigCount;
    }
}
 
Example 19
Source File: ActivityMvpDelegateImpl.java    From mosby with 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 File: ActivityMviDelegateImpl.java    From mosby with 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());
}