本文整理匯總了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);