Hi,
I can detect screen on/off by using PhoneEvents but to check it for long run, I need to use service and must to display notification icon. So I want to detect it by intent with this.
Manifest code:
service1 code:
However, it didn't work. So I need your suggestions. Thank you.
I can detect screen on/off by using PhoneEvents but to check it for long run, I need to use service and must to display notification icon. So I want to detect it by intent with this.
Manifest code:
B4X:
AddPermission(android.permission.READ_PHONE_STATE)
AddReceiverText(service1,
<intent-filter>
<action android:name="android.intent.action.SCREEN_OFF"/>
<action android:name="android.intent.action.SCREEN_ON"/>
</intent-filter>
)
service1 code:
B4X:
Sub Service_Start (StartingIntent As Intent)
If StartingIntent.Action = "android.intent.action.SCREEN_ON" Then
Log("Screen On")
End If
If StartingIntent.Action = "android.intent.action.SCREEN_OFF" Then
Log("Screen Off")
End If
End Sub
However, it didn't work. So I need your suggestions. Thank you.