【问题标题】:How to make our own lock screen in android instead of default lock screen [duplicate]如何在android中制作我们自己的锁屏而不是默认锁屏[重复]
【发布时间】:2014-08-27 05:28:49
【问题描述】:

我有一个想法,要创建自己的手机锁应用程序,类似于 android 模式锁。每当手机启动/重启/电话、锁定/电话和解锁时,我都需要显示或启动我的应用程序。我不知道如何使应用程序出现而不是默认锁定屏幕并隐藏默认锁定屏幕。 所以我的问题是:

  1. 如何显示或启动我的应用而不是默认锁定屏幕
  2. 什么是

    getWindow().addFlags(
      WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | 
      WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | 
      WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | 
      WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    

这有什么帮助?

  1. 什么是

    public class BootReciever extends BroadcastReceiver {
    
        @Override
        public void onReceive(Context context, Intent intent) {
            if (intent.getAction() != null) {
                if (intent.getAction().equals(Intent.ACTION_USER_PRESENT)) {
                Intent s = new  Intent(context,ViewPagerMainActivity.class);
                s.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                context.startActivity(s);
                }
            }
        }
    }
    

这有什么帮助?

  1. 我的应用完成工作后如何显示主页?

【问题讨论】:

标签: java android boot lockscreen


【解决方案1】:

您在第 2 点中使用的代码应用作问题 1 的答案。参考是 Android activity over default lock screen

对于问题 2,请参阅以下相关链接:

在回答你的问题3之前,我想问你,你知道BroadcastReceiver吗?总之就是——

广播接收器(短接收器)是一个 Android 组件,它 允许您注册系统或应用程序事件。全部 Android 运行时通知事件的注册接收者 一旦发生此事件。

例如,应用程序可以注册 ACTION_BOOT_COMPLETED Android 系统完成后触发的系统事件 启动过程。

现在来到你的问题 4,你可以通过这个代码以编程方式显示主页:

Intent startMain = new Intent(Intent.ACTION_MAIN);
startMain.addCategory(Intent.CATEGORY_HOME);
startMain.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(startMain);

参考:Going to home screen programmatically

最后,我想为您提供一些可以帮助您制作自定义锁屏的链接:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-23
    • 1970-01-01
    • 2011-04-16
    • 1970-01-01
    • 2011-04-07
    • 2011-10-18
    相关资源
    最近更新 更多