Java Code Examples for android.app.Application#ActivityLifecycleCallbacks
The following examples show how to use
android.app.Application#ActivityLifecycleCallbacks .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ActivitiesLifecycleCallbacks.java From RxPermissionsResult with Apache License 2.0 | 5 votes |
private void registerActivityLifeCycle() { if (activityLifecycleCallbacks != null) application.unregisterActivityLifecycleCallbacks(activityLifecycleCallbacks); activityLifecycleCallbacks = new Application.ActivityLifecycleCallbacks() { @Override public void onActivityCreated(Activity activity, Bundle savedInstanceState) { liveActivityOrNull = activity; } @Override public void onActivityStarted(Activity activity) {} @Override public void onActivityResumed(Activity activity) { liveActivityOrNull = activity; } @Override public void onActivityPaused(Activity activity) { liveActivityOrNull = null; } @Override public void onActivityStopped(Activity activity) {} @Override public void onActivitySaveInstanceState(Activity activity, Bundle outState) {} @Override public void onActivityDestroyed(Activity activity) {} }; application.registerActivityLifecycleCallbacks(activityLifecycleCallbacks); }
Example 2
Source File: BleManager.java From AsteroidOSSync with GNU General Public License v3.0 | 5 votes |
private void addLifecycleCallbacks() { if( getApplicationContext() instanceof Application ) { final Application application = (Application) getApplicationContext(); final Application.ActivityLifecycleCallbacks callbacks = newLifecycleCallbacks(); application.registerActivityLifecycleCallbacks(callbacks); } else { //--- DRK > Not sure if this is practically possible but nothing we can do here I suppose. } }
Example 3
Source File: PluginManager.java From Neptune with Apache License 2.0 | 5 votes |
/** * 取消插件Application里的ActivityLifeCycle监听 */ public static void unregisterActivityLifecycleCallbacks(Application.ActivityLifecycleCallbacks callback) { synchronized (sActivityLifecycleCallbacks) { sActivityLifecycleCallbacks.remove(callback); } // 对于已经运行的插件,需要从其Application类中反注册 for (Map.Entry<String, PluginLoadedApk> entry : sPluginsMap.entrySet()) { PluginLoadedApk loadedApk = entry.getValue(); if (loadedApk != null && loadedApk.getPluginApplication() != null) { Application application = loadedApk.getPluginApplication(); application.unregisterActivityLifecycleCallbacks(callback); } } }
Example 4
Source File: Config.java From TikTok with Apache License 2.0 | 4 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { lifecycles.add(new ActivityLifecycleCallbacksImpl()); }
Example 5
Source File: LifeCycleMonitor.java From RunMap with Apache License 2.0 | 4 votes |
public Application.ActivityLifecycleCallbacks getLifeCycleCallBack(){ return mLifeStatus; }
Example 6
Source File: GlobalConfiguration.java From Hands-Chopping with Apache License 2.0 | 4 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { lifecycles.add(new ActivityLifecycleCallbacksImpl()); }
Example 7
Source File: AppModule.java From MVPArms with Apache License 2.0 | 4 votes |
@Binds @Named("ActivityLifecycle") abstract Application.ActivityLifecycleCallbacks bindActivityLifecycle(ActivityLifecycle activityLifecycle);
Example 8
Source File: RudenessScreenHelper.java From Rudeness with Apache License 2.0 | 4 votes |
/** * * @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) { } }; }
Example 9
Source File: GlobalConfiguration.java From MVPArms with Apache License 2.0 | 4 votes |
@Override public void injectActivityLifecycle(@NonNull Context context, @NonNull List<Application.ActivityLifecycleCallbacks> lifecycles) { //ActivityLifecycleCallbacks 中的所有方法都会在 Activity (包括三方库) 的对应生命周期中被调用, 所以在对应的方法中可以扩展一些自己需要的逻辑 //可以根据不同的逻辑添加多个实现类 lifecycles.add(new ActivityLifecycleCallbacksImpl()); }
Example 10
Source File: DensityHelper.java From Rudeness with Apache License 2.0 | 4 votes |
/** * * @param application * @param width 设计稿宽度 */ public DensityHelper(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) { } @Override public void onActivityResumed(Activity activity) { } @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) { } }; }
Example 11
Source File: GlobalConfiguration.java From LQRBiliBlili with MIT License | 4 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { //向Activity的生命周期中注入一些自定义逻辑 lifecycles.add(new MyActivityLifecycle()); }
Example 12
Source File: ActivityLifecycleManager.java From twitter-kit-android with Apache License 2.0 | 4 votes |
private void clearCallbacks() { for (Application.ActivityLifecycleCallbacks callback : registeredCallbacks) { application.unregisterActivityLifecycleCallbacks(callback); } }
Example 13
Source File: ActivityCallbacks.java From AndroidCommons with Apache License 2.0 | 4 votes |
public static void register(@NonNull Context context, @NonNull Application.ActivityLifecycleCallbacks listener) { ContextHelper.asApplication(context).registerActivityLifecycleCallbacks(listener); }
Example 14
Source File: GlobalConfiguration.java From lifecycle-component with Apache License 2.0 | 4 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { lifecycles.add(new ActivityLifecycleCallbacksImpl()); }
Example 15
Source File: ConfigLifecycle.java From MVVMArms with Apache License 2.0 | 2 votes |
/** * 使用 {@link Application.ActivityLifecycleCallbacks} 在 Activity 的生命周期中注入一些操作 * * @param context: Context * @param lifecycles: List<Application.ActivityLifecycleCallbacks> */ void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles);
Example 16
Source File: GlobalConfiguration.java From lifecycle-component with Apache License 2.0 | 2 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { }
Example 17
Source File: GlobalConfiguration.java From Hands-Chopping with Apache License 2.0 | 2 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { }
Example 18
Source File: ActivityFragmentControl.java From FastLib with Apache License 2.0 | 2 votes |
/** * ` * Activity 全局生命周期回调 * * @return */ Application.ActivityLifecycleCallbacks getActivityLifecycleCallbacks();
Example 19
Source File: GlobalConfiguration.java From Hands-Chopping with Apache License 2.0 | 2 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { }
Example 20
Source File: GlobalConfiguration.java From lifecycle-component with Apache License 2.0 | 2 votes |
@Override public void injectActivityLifecycle(Context context, List<Application.ActivityLifecycleCallbacks> lifecycles) { }