我正在尝试为具有AMOLED屏幕的设备开发自定义的“始终显示”应用程序,以显示通知甚至时钟。
在屏幕关闭(使用接收器)的情况下,我设法开始了全屏活动,但是随后我想使用指纹扫描仪来取消我的活动(就像本机AOD一样)。
发生的事情是,将手指放在扫描仪上没有任何作用。我需要点击屏幕以显示导航栏,点击“返回”进入本机锁定屏幕,然后使用指纹扫描仪进行解锁。
这是我当前的管理方式(FullscreenActivity.kt):
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_fullscreen)
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
supportActionBar?.setDisplayHomeAsUpEnabled(true)
mVisible = true
// Set up the user interaction to manually show or hide the system UI.
fullscreen_content.setOnClickListener { toggle() }
}
override fun onPostCreate(savedInstanceState: Bundle?) {
super.onPostCreate(savedInstanceState)
Log.log(loggertag, "postcreate")
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O_MR1) {
this.setTurnScreenOn(true)
this.setShowWhenLocked(true)
val keyguardManager = getSystemService(Context.KEYGUARD_SERVICE) as? KeyguardManager?
Log.log(loggertag, "device locked: " + keyguardManager?.isDeviceLocked.toString())
keyguardManager?.requestDismissKeyguard(this, null)
}
// Trigger the initial hide() shortly after the activity has been
// created, to briefly hint to the user that UI controls
// are available.
delayedHide(100)
}
我目前仅针对9.0 Pie。