I have looked through lots of similar questions, and I have found out that it is not possible to make a Lock Screen as the standard android lockers. The thing that is possible is to make an app that disables the LockScreen and uses a different "lock" instead of the standard one. I am thinking about making a custom lockscreen with a different type of lock. What I do not know is possible is:
我已经查看了很多类似的问题,我发现不可能将锁屏作为标准的android锁柜。可能的做法是创建一个禁用LockScreen的应用程序,并使用不同的“锁定”而不是标准的“锁定”。我正在考虑使用不同类型的锁来制作自定义锁屏。我不知道的可能是:
- Are there any ways of useing a .xml layout for a lockscreen
- Can I then write it like a normal app
是否有任何方法可以为锁屏使用.xml布局
我可以像普通的应用程序一样编写它
I do not want referances to existing apps on the market.
我不想要对市场上现有的应用程序进行反馈。
2 个解决方案
#1
1
I believe you are right because i did not find a way to replace the original lockscreen either. As you said, we can disable the original and fake another one.
我相信你是对的,因为我也找不到替换原来的锁屏的方法。如你所说,我们可以禁用原件并伪造另一个。
I have a concept and you can find this page helpful too: http://chandan-tech.blogspot.com/2010/10/handling-screen-lock-unlock-in-android.html
我有一个概念,你也可以找到这个页面:http://chandan-tech.blogspot.com/2010/10/handling-screen-lock-unlock-in-android.html
You disable the original, add a listener to ACTION_SCREEN_ON, and once it is triggered, display your fake lockscreen, and from now you can write it like a normal app and i believe xml layout is totally practical.
您禁用了原始内容,为ACTION_SCREEN_ON添加了一个侦听器,一旦触发它,就会显示您的假锁屏,从现在开始您可以像普通应用程序一样编写它,我相信xml布局是完全实用的。
To actually implement it , a service should also be made and has to run with system startup. In your activity you should also disable notification bar and buttons .
要实际实现它,还应该创建一个服务,并且必须在系统启动时运行。在您的活动中,您还应该禁用通知栏和按钮。
#2
0
You can try overriding KeyguardManager
您可以尝试重写KeyguardManager
KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");
You must insert this in a service.Go as something like:
您必须将其插入服务中。如下所示:
public class LockService extends Service{
BroadcastReceiver receiver;
@override
@SuppressWarnings("deprecation")
public void onCreate(){
KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");
IntentFilter filter=new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
receiver=new LockscreenReceiver();
registerReceiver(receiver,filter);
super.onCreate();
}
And then on LockscreenReceiver, you must implement this action:
然后在LockscreenReceiver上,您必须实现此操作:
public class LockscreenReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context,Intent intent){
String action=intent.getAction();
//if the screen was recently enabled, do this:
//If the screen was just turned on or it just booted up, start your Lock Activity
if(action.equals(Intent.ACTION_SCREEN_OFF) || action.equals(Intent.ACTION_BOOT_COMPLETED))
{
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
afterwards, you must register or call service in MainActivity
之后,您必须在MainActivity中注册或致电服务
startService(new Intent(this,LockscreenService.class));
To see this in action, go to https://github.com/thomasvidas/Simple-Lockscreen
要查看此操作,请访问https://github.com/thomasvidas/Simple-Lockscreen
#1
1
I believe you are right because i did not find a way to replace the original lockscreen either. As you said, we can disable the original and fake another one.
我相信你是对的,因为我也找不到替换原来的锁屏的方法。如你所说,我们可以禁用原件并伪造另一个。
I have a concept and you can find this page helpful too: http://chandan-tech.blogspot.com/2010/10/handling-screen-lock-unlock-in-android.html
我有一个概念,你也可以找到这个页面:http://chandan-tech.blogspot.com/2010/10/handling-screen-lock-unlock-in-android.html
You disable the original, add a listener to ACTION_SCREEN_ON, and once it is triggered, display your fake lockscreen, and from now you can write it like a normal app and i believe xml layout is totally practical.
您禁用了原始内容,为ACTION_SCREEN_ON添加了一个侦听器,一旦触发它,就会显示您的假锁屏,从现在开始您可以像普通应用程序一样编写它,我相信xml布局是完全实用的。
To actually implement it , a service should also be made and has to run with system startup. In your activity you should also disable notification bar and buttons .
要实际实现它,还应该创建一个服务,并且必须在系统启动时运行。在您的活动中,您还应该禁用通知栏和按钮。
#2
0
You can try overriding KeyguardManager
您可以尝试重写KeyguardManager
KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");
You must insert this in a service.Go as something like:
您必须将其插入服务中。如下所示:
public class LockService extends Service{
BroadcastReceiver receiver;
@override
@SuppressWarnings("deprecation")
public void onCreate(){
KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");
IntentFilter filter=new IntentFilter(Intent.ACTION_SCREEN_ON);
filter.addAction(Intent.ACTION_SCREEN_OFF);
filter.addAction(Intent.ACTION_BOOT_COMPLETED);
receiver=new LockscreenReceiver();
registerReceiver(receiver,filter);
super.onCreate();
}
And then on LockscreenReceiver, you must implement this action:
然后在LockscreenReceiver上,您必须实现此操作:
public class LockscreenReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context,Intent intent){
String action=intent.getAction();
//if the screen was recently enabled, do this:
//If the screen was just turned on or it just booted up, start your Lock Activity
if(action.equals(Intent.ACTION_SCREEN_OFF) || action.equals(Intent.ACTION_BOOT_COMPLETED))
{
Intent i = new Intent(context, MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
}
}
afterwards, you must register or call service in MainActivity
之后,您必须在MainActivity中注册或致电服务
startService(new Intent(this,LockscreenService.class));
To see this in action, go to https://github.com/thomasvidas/Simple-Lockscreen
要查看此操作,请访问https://github.com/thomasvidas/Simple-Lockscreen