自定义锁屏延迟当唤醒 [英] Custom Lock Screen Delay When Wake

查看:162
本文介绍了自定义锁屏延迟当唤醒的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使自定义锁屏应用程序,但我不知道如果我要了解它的正确途径。我有一个广播接收器监听当屏幕开启并开始我的锁屏的活动。该接收器注册一个服务,这也禁用默认锁屏内。

现在的问题是,有当屏幕开启和锁定屏幕活动显示了之间稍有延迟。我怎么会去这样做,以便它显示出来的时候了?

我的code的服务:

  @覆盖
公共无效的onCreate(){
    super.onCreate();
    IntentFilter的过滤器=新的IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver的powerReceiver =新PowerReceiver();
    registerReceiver(powerReceiver,过滤器);
}

@覆盖
公众诠释onStartCommand(意向意图,诠释标志,诠释startId){

    KeyguardManager keyguardManager =(KeyguardManager)getSystemService(Service.KEYGUARD_SERVICE);
    KeyguardLock锁= keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
    lock.disableKeyguard();

    返回Service.START_STICKY;
}

@覆盖
公众的IBinder onBind(意向意图){
    返回null;
}
 

和接收器:

  @覆盖
公共无效的onReceive(上下文的背景下,意图意图){
    如果(intent.getAction()。等于(Intent.ACTION_SCREEN_ON)){
        意图showScreen =新的意图(背景下,LockScreen.class);
        showScreen.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(showScreen);


    }

}
 

解决方案

打开你的应用程序到主屏幕更换应用程序,而当用户成功解除自定义锁屏,你可以带他们到默认主页的应用程序。

您可以找到更多的相关信息<一个href="http://stackoverflow.com/questions/8248213/use-my-own-android-app-apk-as-launcher-home-screen-replacement">question和这些的问题。

I'm trying to make a custom lock screen app, but I'm not sure if I'm going about it the right way. I have a broadcast receiver that listens to when the screen is turned on and starts my lock screen activity. This receiver is registered inside a service, which also disables the default lock screen.

The problem is, there is a slight delay between when the screen is turned on and the lock screen activity shows up. How would I go about doing it so that it shows up right away?

My code for the service:

@Override
public void onCreate() {
    super.onCreate();
    IntentFilter filter = new IntentFilter(Intent.ACTION_SCREEN_ON);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver powerReceiver = new PowerReceiver();
    registerReceiver(powerReceiver, filter);
}

@Override
public int onStartCommand(Intent intent, int flags, int startId) {  

    KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Service.KEYGUARD_SERVICE);
    KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);
    lock.disableKeyguard();

    return Service.START_STICKY;
}

@Override
public IBinder onBind(Intent intent) {
    return null;
}

and the receiver:

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
        Intent showScreen = new Intent(context, LockScreen.class);
        showScreen.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(showScreen);


    }   

}

解决方案

Turn your app into a home screen replacement app and when the user successfully unlocks the custom lock screen you can take them to the default home app.

You can find more info in this question and these questions.

这篇关于自定义锁屏延迟当唤醒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆