當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。