dune3000 Member Licensed User Longtime User Oct 24, 2022 #1 Hi, I want to catch the power connected event by add receiver to manifest.xml B4X: Copy AddReceiverText(PowerConnectedReceiver, <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> </intent-filter>) and a service module named PowerConnectedReceiver, B4X: Copy Sub Service_Start (StartingIntent As Intent) Log("Power Connected!") Service.StopAutomaticForeground 'Call this when the background task completes (if there is one) End Sub but no effect, any sugguestion? Thanks
Hi, I want to catch the power connected event by add receiver to manifest.xml B4X: Copy AddReceiverText(PowerConnectedReceiver, <intent-filter> <action android:name="android.intent.action.ACTION_POWER_CONNECTED"/> </intent-filter>) and a service module named PowerConnectedReceiver, B4X: Copy Sub Service_Start (StartingIntent As Intent) Log("Power Connected!") Service.StopAutomaticForeground 'Call this when the background task completes (if there is one) End Sub but no effect, any sugguestion? Thanks
DonManfred Expert Licensed User Longtime User Oct 24, 2022 #2 How to listen for power connected Android > 8 I have a simple Android Kotlin app, and part of what it does is listen for when power is connected and disconnected and perform an action This is my old code, and it worked totally fine while targ... stackoverflow.com Upvote 0
How to listen for power connected Android > 8 I have a simple Android Kotlin app, and part of what it does is listen for when power is connected and disconnected and perform an action This is my old code, and it worked totally fine while targ... stackoverflow.com
OliverA Expert Licensed User Longtime User Oct 24, 2022 #3 Would the Battery_Changed event of the PhoneEvents library not suffice? Code: Copy Sub Process_Globals '... Private pe As PhoneEvents '... End Sub Sub Service_Create '... pe.Initialize("pe") '... End Sub Sub pe_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent) Log(Plugged) End Sub Upvote 0
Would the Battery_Changed event of the PhoneEvents library not suffice? Code: Copy Sub Process_Globals '... Private pe As PhoneEvents '... End Sub Sub Service_Create '... pe.Initialize("pe") '... End Sub Sub pe_BatteryChanged (Level As Int, Scale As Int, Plugged As Boolean, Intent As Intent) Log(Plugged) End Sub
dune3000 Member Licensed User Longtime User Oct 24, 2022 #4 Thank you @DonManfred, you pointed me to the right direction, now I just changed the targetSdkVersion to "25", and it works! @OliverA, because I want to catch power connected and power disconnected events. Upvote 0
Thank you @DonManfred, you pointed me to the right direction, now I just changed the targetSdkVersion to "25", and it works! @OliverA, because I want to catch power connected and power disconnected events.