本文整理汇总了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);
}
}
示例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;
}
示例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);
}
}
示例4: registerActivityLifecycleCallbacks
import android.app.Application; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registerActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callback) {
getApplication().registerActivityLifecycleCallbacks(callback);
}
示例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);
}
示例6: registerActivityLifecycleCallback
import android.app.Application; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH)
public void registerActivityLifecycleCallback(Application.ActivityLifecycleCallbacks callbacks) {
getApplication().registerActivityLifecycleCallbacks(callbacks);
}
示例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) {
}
};
}
示例8: injectActivityLifecycle
import android.app.Application; //导入方法依赖的package包/类
@Override
public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) {
// ActivityLifecycleCallbacks 的所有方法都会在 Activity (包括三方库) 的对应的生命周期中被调用,所以在对应的方法中可以扩展一些自己需要的逻辑
// 可以根据不同的逻辑添加多个实现类
lifecycles.add(new ActivityLifecycleCallbacksImpl());
}
示例9: getLifeCycleCallBack
import android.app.Application; //导入方法依赖的package包/类
public Application.ActivityLifecycleCallbacks getLifeCycleCallBack(){
return mLifeStatus;
}
示例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);
}
示例11: injectActivityLifecycle
import android.app.Application; //导入方法依赖的package包/类
@Override
public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) {
//向Activity的生命周期中注入一些自定义逻辑
lifecycles.add(new MyActivityLifecycle());
}
示例12: injectActivityLifecycle
import android.app.Application; //导入方法依赖的package包/类
/**
* 使用{@link Application.ActivityLifecycleCallbacks}在Activity的生命周期中注入一些操作
*
* @param context
* @param lifecycles
*/
void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles);
示例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);
示例14: injectActivityLifeCycles
import android.app.Application; //导入方法依赖的package包/类
/**
* @param context
* @param activityLifeCycles
*/
void injectActivityLifeCycles(Context context, List<Application.ActivityLifecycleCallbacks> activityLifeCycles);
示例15: getLifecycle
import android.app.Application; //导入方法依赖的package包/类
Application.ActivityLifecycleCallbacks getLifecycle(String key);