Java 类android.app.Application.ActivityLifecycleCallbacks 实例源码

项目:boohee_v5.6    文件:Session.java   
@TargetApi(14)
public static void setAutoSession(Application application) {
    MWConfiguration.initContext(application.getApplicationContext());
    if (VERSION.SDK_INT >= 14) {
        try {
            ActivityLifecycleCallbacks xVar = new x();
            application.unregisterActivityLifecycleCallbacks(xVar);
            application.registerActivityLifecycleCallbacks(xVar);
            m.a().h(true);
        } catch (NoSuchMethodError e) {
            m.a().h(false);
        } catch (NoClassDefFoundError e2) {
            m.a().h(false);
        }
    }
}
项目:pixate-freestyle-android    文件:PixateFreestyle.java   
@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);
    }

}
项目:AndZilla    文件:ActivityLifeCycle.java   
private ActivityLifecycleCallbacks getLifeCycle(Activity activity){
    String fullName=activity.getClass().getName();
    //通过activity的名字获取对应的生命周期注册对象
    if(manager!=null){
        return manager.getLifecycle(fullName);
    }
    return null;
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivityCreated(activity,savedInstanceState);
    }
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivityStarted(Activity activity) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivityStarted(activity);
    }
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivityResumed(Activity activity) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivityResumed(activity);
    }
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivityPaused(Activity activity) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivityPaused(activity);
    }
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivityStopped(Activity activity) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivityStopped(activity);
    }
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivitySaveInstanceState(Activity activity, Bundle outState) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivitySaveInstanceState(activity,outState);
    }
}
项目:AndZilla    文件:ActivityLifeCycle.java   
@Override
public void onActivityDestroyed(Activity activity) {
    ActivityLifecycleCallbacks callbacks=getLifeCycle(activity);
    if(callbacks!=null){
        callbacks.onActivityDestroyed(activity);
    }
}
项目:RxAppState    文件:DefaultAppStateRecognizerSetupTest.java   
@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));
}
项目:RxAppState    文件:DefaultAppStateRecognizerSetupTest.java   
@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));
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:agera    文件:RepositoryAdapterTest.java   
@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);
}
项目:letv    文件:k.java   
public static void a(Application application) {
    ActivityLifecycleCallbacks lVar = new l();
    application.unregisterActivityLifecycleCallbacks(lVar);
    application.registerActivityLifecycleCallbacks(lVar);
}
项目:letv    文件:ActivityLifecycleManager.java   
@TargetApi(14)
private void clearCallbacks() {
    for (ActivityLifecycleCallbacks callback : this.registeredCallbacks) {
        this.application.unregisterActivityLifecycleCallbacks(callback);
    }
}