Android Question To wake screen off with a service

brelto85

Active Member
Licensed User
Longtime User
Hi,

In my app i've a service that runs in a foreground mode and that checks the voice recognition (using SpeechRecognizer library)
When the results of recognizer are fired, is called a method in a main activity with the follow code:

B4X:
Sub SpeechRecognition_Results (Words As List)
        StopService("")
        If IsPaused(MainActivity) Then
            StartActivity(MainActivity)
        Else
              CallSubDelayed(MainActivity, "StartVRAction")
        End If      
End Sub

The question is that if the screen is off and the app runs only with service running (MainActivity is hide with home button) the screen turn on correctly

If the MainActivity is active, the screen do not turn on after voice recognition result (CallSubDelayed)

Some idea to do this?

Alberto
 

brelto85

Active Member
Licensed User
Longtime User
"The PhoneWakeState object allows you to prevent the device from turning off the screen."

I would turn on the screen when it turned off

B4X:
Sub SpeechRecognition_Results (Words As List)
        StopService("")
        If IsPaused(MainActivity) Then
            StartActivity(MainActivity)
        Else
              '???????????????
              CallSubDelayed(MainActivity, "StartVRAction")
        End If     
End Sub

alberto
 
Upvote 0
Top