freedom2000 Well-Known Member Licensed User Longtime User May 16, 2014 #1 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 : Code: Copy AddReceiverText(unlock, <intent-filter> <action android:name="android.intent.action.SCREEN_ON" /> </intent-filter>) then added this code in my service : Code: Copy 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
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 : Code: Copy AddReceiverText(unlock, <intent-filter> <action android:name="android.intent.action.SCREEN_ON" /> </intent-filter>) then added this code in my service : Code: Copy 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
thedesolatesoul Expert Licensed User Longtime User May 16, 2014 #2 Try to also add category default in the receiver. Also, the StartingIntent.HasExtra will not have the intent name. Upvote 0
Try to also add category default in the receiver. Also, the StartingIntent.HasExtra will not have the intent name.
freedom2000 Well-Known Member Licensed User Longtime User May 16, 2014 #3 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 : Code: Copy 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: May 17, 2014 Upvote 0
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 : Code: Copy 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
Erel B4X founder Staff member Licensed User Longtime User May 18, 2014 #4 I wanted to avoid having a foreground service always running to trap this event... but probably impossible Click to expand... That is correct. This intent can only be captured with a dynamic intent filter. Upvote 0
I wanted to avoid having a foreground service always running to trap this event... but probably impossible Click to expand... That is correct. This intent can only be captured with a dynamic intent filter.
freedom2000 Well-Known Member Licensed User Longtime User May 18, 2014 #5 Erel said: That is correct. This intent can only be captured with a dynamic intent filter. Click to expand... Thank you Erel for this confirmation. Upvote 0
Erel said: That is correct. This intent can only be captured with a dynamic intent filter. Click to expand... Thank you Erel for this confirmation.