android.app.Application.ActivityLifecycleCallbacks Java Examples

The following examples show how to use android.app.Application.ActivityLifecycleCallbacks. 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: PixateFreestyle.java    From pixate-freestyle-android with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
private static void initApp(Context context) {

    Application application = (Application) mAppContext;

    if (application != null) {
        mAppInited = true;
        if (mLifecycleCallbacks == null) {
            mLifecycleCallbacks = new PXLifecycleCallbacks();
        }
        application
                .unregisterActivityLifecycleCallbacks((ActivityLifecycleCallbacks) mLifecycleCallbacks);
        application
                .registerActivityLifecycleCallbacks((ActivityLifecycleCallbacks) mLifecycleCallbacks);
    }

}
 
Example #2
Source File: DefaultAppStateRecognizerSetupTest.java    From RxAppState with MIT License 5 votes vote down vote up
@Test
public void registersCallbacks() {
  recognizer.start();

  verify(mockApplication).registerActivityLifecycleCallbacks(any(ActivityLifecycleCallbacks.class));
  verify(mockApplication).registerComponentCallbacks(any(ComponentCallbacks2.class));
  verify(mockApplication).registerReceiver(any(BroadcastReceiver.class), any(IntentFilter.class));
}
 
Example #3
Source File: DefaultAppStateRecognizerSetupTest.java    From RxAppState with MIT License 5 votes vote down vote up
@Test
public void unregistersCallbacks() {
  recognizer.start();
  recognizer.stop();

  verify(mockApplication).unregisterActivityLifecycleCallbacks(any(ActivityLifecycleCallbacks.class));
  verify(mockApplication).unregisterComponentCallbacks(any(ComponentCallbacks2.class));
  verify(mockApplication).unregisterReceiver(any(BroadcastReceiver.class));
}
 
Example #4
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void setActivityToCreated() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivityCreated(activity, null);
}
 
Example #5
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void setActivityToDestroyed() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivityDestroyed(activity);
}
 
Example #6
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void setActivityToResumed() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivityResumed(activity);
}
 
Example #7
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void setActivityToPaused() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivityPaused(activity);
}
 
Example #8
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void setActivityToStarted() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivityStarted(activity);
}
 
Example #9
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void setActivityToStopped() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivityStopped(activity);
}
 
Example #10
Source File: RepositoryAdapterTest.java    From agera with Apache License 2.0 5 votes vote down vote up
@TargetApi(ICE_CREAM_SANDWICH)
private void saveActivityInstanceState() {
  final ArgumentCaptor<ActivityLifecycleCallbacks> captor =
      forClass(ActivityLifecycleCallbacks.class);

  verify(application).registerActivityLifecycleCallbacks(captor.capture());

  final ActivityLifecycleCallbacks callbacks = captor.getValue();

  callbacks.onActivitySaveInstanceState(activity, null);
}
 
Example #11
Source File: AcgNewsConfig.java    From AcgClub with MIT License 4 votes vote down vote up
@Override
public void injectActivityLifecycle(Context context,
    List<ActivityLifecycleCallbacks> lifecycles) {

}
 
Example #12
Source File: AcgScheduleConfig.java    From AcgClub with MIT License 4 votes vote down vote up
@Override
public void injectActivityLifecycle(Context context,
    List<ActivityLifecycleCallbacks> lifecycles) {

}
 
Example #13
Source File: AppConfig.java    From AcgClub with MIT License 4 votes vote down vote up
@Override
public void injectActivityLifecycle(Context context,
    List<ActivityLifecycleCallbacks> lifecycles) {
}
 
Example #14
Source File: k.java    From letv with Apache License 2.0 4 votes vote down vote up
public static void a(Application application) {
    ActivityLifecycleCallbacks lVar = new l();
    application.unregisterActivityLifecycleCallbacks(lVar);
    application.registerActivityLifecycleCallbacks(lVar);
}
 
Example #15
Source File: ActivityLifecycleManager.java    From letv with Apache License 2.0 4 votes vote down vote up
@TargetApi(14)
private void clearCallbacks() {
    for (ActivityLifecycleCallbacks callback : this.registeredCallbacks) {
        this.application.unregisterActivityLifecycleCallbacks(callback);
    }
}