美文网首页
Application pin code逻辑实现

Application pin code逻辑实现

作者: 花艺荣 | 来源:发表于2020-04-17 22:23 被阅读0次
public class AppCoreBase extends Application implements Application.ActivityLifecycleCallback

    public void onCreate()
    {       


        mScreenObserver = new ScreenObserver(getApplicationContext());
        mScreenObserver.requestScreenStateUpdate(new ScreenObserver.ScreenStateListener() {
            @Override
            public void onScreenOn() {
                doSomethingOnScreenOn();
            }
            @Override
            public void onScreenOff() {
                doSomethingOnScreenOff();
            }
        });
        registerActivityLifecycleCallbacks(this);
        
    }

    @Override
    public void onTerminate() {
        super.onTerminate();
        mScreenObserver.stopScreenStateUpdate();
        unregisterActivityLifecycleCallbacks(this);

    }

@Override
    public void onActivityStarted(@NonNull Activity activity) {

    }
    @Override
    public void onActivityStopped(@NonNull Activity activity) {

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

    }
    @Override
    public void onActivityDestroyed(@NonNull Activity activity) {

    }
    @Override
    public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
          
    }
    @Override
    public void onActivityResumed(@NonNull Activity activity) {     
            //  do something here
    }

    @Override
    public void onActivityPaused(@NonNull Activity activity) {
             //  do something here
    }


相关文章

网友评论

      本文标题:Application pin code逻辑实现

      本文链接:https://www.haomeiwen.com/subject/nenuvhtx.html