“锁定屏幕”与自定义安全密码
问题描述:
我看了很多类似的问题,我发现它是而不是可能使锁屏作为标准的android储物柜。可能的事情是制作一个禁用LockScreen的应用程序,并使用不同的“锁定”而不是标准的锁定。我正在考虑使用不同类型的锁定自定义锁定屏幕。我不知道是可能的是:“锁定屏幕”与自定义安全密码
- 是否有锁屏期运用为.xml布局的任何方式
- 我可以接着写它像一个正常的应用程序
我不想对市场上现有应用程序的重新评估。
答
我相信你是对的,因为我没有找到一种方法来取代原来的锁屏。正如你所说,我们可以禁用原来的,假的另一个。
我有一个概念,你可以找到这个页面也有帮助:http://chandan-tech.blogspot.com/2010/10/handling-screen-lock-unlock-in-android.html
您禁用原,添加侦听ACTION_SCREEN_ON,一旦被触发,显示你的假锁屏,从现在开始你可以写它就像一个普通的应用程序,我相信xml布局是完全实用的。
要真正实现它,还应该创建服务并且必须在系统启动时运行。在你的活动中,你也应该禁用通知栏和按钮。
答
你可以尝试重写KeyguardManager
KeyguardManager.KeyguardLock key;
KeyguardManager km=(KeyguardManager)getSystemService(KEYGUARD_SERVICE);
//depreciated
key=km.newKeyguardLock("IN");
您必须在service.Go作为像插入此:
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();
}
,然后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);
}
}
}
之后,您必须在MainActivity注册或致电服务
startService(new Intent(this,LockscreenService.class));
非常感谢链接 – Magakahn 2012-03-03 20:41:56