Android Question Screen on intent

freedom2000

Well-Known Member
Licensed User
Longtime User
Hi,
I wanted to register for a SCREEN_ON intent to start a service

I found this intent and created a filter in the manifest :

B4X:
  AddReceiverText(unlock, <intent-filter>
    <action android:name="android.intent.action.SCREEN_ON" />
    </intent-filter>)

then added this code in my service :

B4X:
Sub Service_Start (StartingIntent As Intent)
    'ToastMessageShow("service start", False)   

If (StartingIntent.HasExtra("android.intent.action.SCREEN_ON")) Then
    ToastMessageShow("screen on", False)
End If
End Sub

but I never receive the intent for the SCREEN_ON event.

For sure I know how to create a service and wait for the screen_on event inside this service with the phone events library.

But I wanted to test it with an intent.
Is there a way to have it run ?

thanks
 

freedom2000

Well-Known Member
Licensed User
Longtime User
Thank you for this fast answer,but i do not totally understand what to do with the intent
Name.
Could you please précise ?

I however tried to add default in the manifiest :

B4X:
  AddReceiverText(unlock, <intent-filter>
    <action android:name="android.intent.action.SCREEN_ON" />
    <category android:name="android.intent.category.DEFAULT" />
    </intent-filter>)

but the intent doesn't fire in the start service...

Searching a while on google gives no real chance of success.

see here : http://stackoverflow.com/questions/...en-on-doesnt-work-as-a-receiver-intent-filter

I wanted to avoid having a foreground service always running to trap this event... but probably impossible
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…