从锁定屏幕点击通知操作时解锁屏幕

时间:2017-12-22 20:27:04

标签: java android

当屏幕被锁定且用户从锁定屏幕中选择对通知操作的肯定响应时,如何添加代码以提示屏幕解锁?以下是我已添加到通知构建器的当前正面通知操作的代码,当选择此操作时,我在类中添加了一个intent,它扩展了IntentService以导航到应用程序中的活动:

Option Explicit

Sub LoopPivot()

With Sheet1

    Dim pt As PivotTable
    Set pt = .PivotTables(1)

    Dim nameField As PivotField
    Set nameField = pt.PivotFields("Name")

    Dim nameItem As PivotItem

    For Each nameItem In nameField.PivotItems

        Dim name As String
        name = nameItem.Value

        Dim emailField As PivotField
        Set emailField = pt.PivotFields("email")

        Dim emailItem As PivotItem
        Set emailItem = emailField.PivotItems(nameItem.Position)

        Dim email As String
        email = emailItem.Value

        Dim divisionName As Range

        Dim division As String
        division = vbNullString

        For Each divisionName In nameItem.DataRange

            division = division & "," & divisionName.Value

        Next

        division = Mid(division, 2, 255)

        Debug.Print name
        Debug.Print email
        Debug.Print division


    Next

End With


End Sub

1 个答案:

答案 0 :(得分:0)

要在Android中启用或停用锁定屏幕,我们需要获取KeyguardManager

的实例
KeyguardManager keyguardManager = (KeyguardManager)getSystemService(Activity.KEYGUARD_SERVICE);  
KeyguardLock lock = keyguardManager.newKeyguardLock(KEYGUARD_SERVICE);  

并禁用锁定使用,

lock.disableKeyguard();

当然,我们需要Manifest中的许可

android.permission.DISABLE_KEYGUARD