当前位置: 首页>>代码示例>>Java>>正文


Java Application.ActivityLifecycleCallbacks方法代码示例

本文整理汇总了Java中android.app.Application.ActivityLifecycleCallbacks方法的典型用法代码示例。如果您正苦于以下问题:Java Application.ActivityLifecycleCallbacks方法的具体用法?Java Application.ActivityLifecycleCallbacks怎么用?Java Application.ActivityLifecycleCallbacks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Application的用法示例。


在下文中一共展示了Application.ActivityLifecycleCallbacks方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onCreate

import android.app.Application; //导入方法依赖的package包/类
public void onCreate() {
    mAppComponent = DaggerAppComponent.builder()
            .appModule(new AppModule(mApplication))
            .clientModule(new ClientModule())
            .globalModule(getGlobalModule(mApplication, mConfigModules))
            .build();

    mAppComponent.inject(this);

    mAppComponent.extras().put(ConfigModule.class.getSimpleName(), mConfigModules);

    for (ConfigModule module : mConfigModules) {
        module.registerComponents(mApplication, mAppComponent.getIRepositoryManager());
    }

    mApplication.registerActivityLifecycleCallbacks(mActivityLifeCycle);

    for (Application.ActivityLifecycleCallbacks activityLifecycleCallbacks : mActivityLifeCycles) {
        mApplication.registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
    }

    for (LifeCycle lifeCycle : mAppLifeCycles) {
        lifeCycle.onCreate(mApplication);
    }

}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:27,代码来源:AppDelegate.java

示例2: onTerminal

import android.app.Application; //导入方法依赖的package包/类
public void onTerminal() {
    if (mAppLifeCycles != null) {
        for (LifeCycle lifeCycle : mAppLifeCycles) {
            lifeCycle.onTerminate(mApplication);
        }
    }

    if (mActivityLifeCycle != null) {
        mApplication.unregisterActivityLifecycleCallbacks(mActivityLifeCycle);
    }

    if (mActivityLifeCycles != null && !mActivityLifeCycles.isEmpty()) {
        for (Application.ActivityLifecycleCallbacks activityLifecycleCallbacks : mActivityLifeCycles) {
            mApplication.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks);
        }
    }

    this.mAppLifeCycles = null;
    this.mActivityLifeCycle = null;
    this.mActivityLifeCycles = null;
    this.mAppComponent = null;
    this.mApplication = null;


}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:26,代码来源:AppDelegate.java

示例3: unregisterActivityEventCallback

import android.app.Application; //导入方法依赖的package包/类
private void unregisterActivityEventCallback(Application application)
{
    Webtrekk webtrekk = Webtrekk.getInstance();

    Application.ActivityLifecycleCallbacks callbacks = (Application.ActivityLifecycleCallbacks)returnHiddenField(webtrekk, "mActivityStatus");
    if (callbacks != null)
    {
        application.unregisterActivityLifecycleCallbacks(callbacks);
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:11,代码来源:SDKInstanceManager.java

示例4: registerActivityLifecycleCallbacks

import android.app.Application; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registerActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callback) {
    getApplication().registerActivityLifecycleCallbacks(callback);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:AndroidApplication.java

示例5: registerActivityLifecycleCallbacks

import android.app.Application; //导入方法依赖的package包/类
private synchronized void registerActivityLifecycleCallbacks(Application context) {
    if (activityLifecycleCallbacks != null) {
        return;
    }
    activityLifecycleCallbacks = new Application.ActivityLifecycleCallbacks() {
        @Override
        public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
        }

        @Override
        public void onActivityStarted(Activity activity) {
            System.out.println("======onActivityStarted============"+activity);

        }

        @Override
        public void onActivityResumed(Activity activity) {
            System.out.println("======onActivityResumed============"+activity);

            GiraffePlayer currentPlayer = getPlayerByFingerprint(activity2playersRef.get(activity));
            if (currentPlayer != null) {
                currentPlayer.onActivityResumed();
            }
            topActivityRef = new WeakReference<>(activity);
        }

        @Override
        public void onActivityPaused(Activity activity) {
            System.out.println("======onActivityPaused============"+activity);
            GiraffePlayer currentPlayer = getPlayerByFingerprint(activity2playersRef.get(activity));
            if (currentPlayer != null) {
                currentPlayer.onActivityPaused();
            }
            if (topActivityRef!=null && topActivityRef.get() == activity) {
                topActivityRef.clear();
            }
        }

        @Override
        public void onActivityStopped(Activity activity) {
            System.out.println("======onActivityStopped============"+activity);

        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

        }

        @Override
        public void onActivityDestroyed(Activity activity) {
            GiraffePlayer currentPlayer = getCurrentPlayer();
            if (currentPlayer != null) {
                currentPlayer.onActivityDestroyed();
            }
            activity2playersRef.remove(activity);
        }
    };
    context.registerActivityLifecycleCallbacks(activityLifecycleCallbacks);
}
 
开发者ID:tcking,项目名称:GiraffePlayer2,代码行数:61,代码来源:PlayerManager.java

示例6: registerActivityLifecycleCallback

import android.app.Application; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registerActivityLifecycleCallback(Application.ActivityLifecycleCallbacks callbacks) {
    getApplication().registerActivityLifecycleCallbacks(callbacks);
}
 
开发者ID:GitLqr,项目名称:HotFixDemo,代码行数:5,代码来源:SampleApplicationLike.java

示例7: RudenessScreenHelper

import android.app.Application; //导入方法依赖的package包/类
/**
 *
 * @param application application
 * @param width 设计稿宽度
 */
public RudenessScreenHelper(Application application, float width){
    mApplication = application;
    designWidth = width;

    activityLifecycleCallbacks = new Application.ActivityLifecycleCallbacks() {
        @Override
        public void onActivityCreated(Activity activity, Bundle savedInstanceState) {
            //通常情况下application与activity得到的resource虽然不是一个实例,但是displayMetrics是同一个实例,只需调用一次即可
            //为了面对一些不可预计的情况以及向上兼容,分别调用一次较为保险
            resetDensity(mApplication, designWidth);
            resetDensity(activity, designWidth);
        }

        @Override
        public void onActivityStarted(Activity activity) {
            resetDensity(mApplication, designWidth);
            resetDensity(activity, designWidth);
        }

        @Override
        public void onActivityResumed(Activity activity) {
            resetDensity(mApplication, designWidth);
            resetDensity(activity, designWidth);
        }

        @Override
        public void onActivityPaused(Activity activity) {

        }

        @Override
        public void onActivityStopped(Activity activity) {

        }

        @Override
        public void onActivitySaveInstanceState(Activity activity, Bundle outState) {

        }

        @Override
        public void onActivityDestroyed(Activity activity) {

        }
    };
}
 
开发者ID:Firedamp,项目名称:Rudeness,代码行数:52,代码来源:RudenessScreenHelper.java

示例8: injectActivityLifecycle

import android.app.Application; //导入方法依赖的package包/类
@Override
public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) {
    // ActivityLifecycleCallbacks 的所有方法都会在 Activity (包括三方库) 的对应的生命周期中被调用,所以在对应的方法中可以扩展一些自己需要的逻辑
    // 可以根据不同的逻辑添加多个实现类
    lifecycles.add(new ActivityLifecycleCallbacksImpl());
}
 
开发者ID:Superingxz,项目名称:MoligyMvpArms,代码行数:7,代码来源:GlobalConfiguration.java

示例9: getLifeCycleCallBack

import android.app.Application; //导入方法依赖的package包/类
public Application.ActivityLifecycleCallbacks getLifeCycleCallBack(){
    return mLifeStatus;
}
 
开发者ID:stdnull,项目名称:RunMap,代码行数:4,代码来源:LifeCycleMonitor.java

示例10: init

import android.app.Application; //导入方法依赖的package包/类
/**
 * 初始化工具类
 *
 * @param app 应用
 */
public static void init(final Application app) {
	Utils.sApplication = app;
	callbacks  = new Application.ActivityLifecycleCallbacks() {
		@Override
		public void onActivityCreated(Activity activity, Bundle bundle) {
			sActivityList.add(activity);
			setTopActivityWeakRef(activity);
		}

		@Override
		public void onActivityStarted(Activity activity) {
			setTopActivityWeakRef(activity);
		}

		@Override
		public void onActivityResumed(Activity activity) {
			setTopActivityWeakRef(activity);
		}

		@Override
		public void onActivityPaused(Activity activity) {

		}

		@Override
		public void onActivityStopped(Activity activity) {

		}

		@Override
		public void onActivitySaveInstanceState(Activity activity, Bundle bundle) {

		}

		@Override
		public void onActivityDestroyed(Activity activity) {
			sActivityList.remove(activity);
		}
	};
	app.registerActivityLifecycleCallbacks(callbacks);
}
 
开发者ID:MobClub,项目名称:BBSSDK-for-Android,代码行数:47,代码来源:Utils.java

示例11: injectActivityLifecycle

import android.app.Application; //导入方法依赖的package包/类
@Override
public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) {
    //向Activity的生命周期中注入一些自定义逻辑
    lifecycles.add(new MyActivityLifecycle());
}
 
开发者ID:GitLqr,项目名称:LQRBiliBlili,代码行数:6,代码来源:GlobalConfiguration.java

示例12: injectActivityLifecycle

import android.app.Application; //导入方法依赖的package包/类
/**
 * 使用{@link Application.ActivityLifecycleCallbacks}在Activity的生命周期中注入一些操作
 *
 * @param context
 * @param lifecycles
 */
void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles);
 
开发者ID:RockyQu,项目名称:MVVMFrames,代码行数:8,代码来源:ConfigModule.java

示例13: injectActivityLifecycle

import android.app.Application; //导入方法依赖的package包/类
/**
 * Use {@link Application.ActivityLifecycleCallbacks} to inject some actions in the Activity lifecycle
 *
 * @param context:    Context
 * @param lifecycles: List of Application.ActivityLifecycleCallbacks
 */
void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles);
 
开发者ID:goutham106,项目名称:GmArchMvvm,代码行数:8,代码来源:ConfigLifecycle.java

示例14: injectActivityLifeCycles

import android.app.Application; //导入方法依赖的package包/类
/**
 * @param context
 * @param activityLifeCycles
 */
void injectActivityLifeCycles(Context context, List<Application.ActivityLifecycleCallbacks> activityLifeCycles);
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:6,代码来源:ConfigModule.java

示例15: getLifecycle

import android.app.Application; //导入方法依赖的package包/类
Application.ActivityLifecycleCallbacks getLifecycle(String key); 
开发者ID:zillachan,项目名称:AndZilla,代码行数:2,代码来源:ILifecycleManager.java


注:本文中的android.app.Application.ActivityLifecycleCallbacks方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。