Wireless Standby and how to get to active mode

aj11

Member
Licensed User
Longtime User
Hi, everyone!
First my deep respect to Erel. You've made programing for Android(and earlier for PPC) much, much easier..

Now I have a little problem. I am using Sony PRS T1 eReader(rooted) for an database computer. It has nice ability, that after 5 minutes of wireless inactivity goes to sleep mode. If I open browser it automaticaly goes to active mode, but I realy have no success wakeing it up with b4A. I am using FTP for sending stored data (converted to csv file) to www. Any suggestion what (and how) to do?!

Kind Regards
Ales
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
You can use this code to enable or disable wifi (requires Reflection library):
B4X:
Sub Activity_Create (FirstTime As Boolean)
   SetWifi(True)
End Sub

Sub SetWifi (Enabled As Boolean)
   Dim r As Reflector
   r.Target = r.GetContext
   r.Target = r.RunMethod2("getSystemService", "wifi", "java.lang.String")
   r.RunMethod2("setWifiEnabled", Enabled, "java.lang.boolean")
End Sub

You will need to add the following code to the manifest editor:
B4X:
AddPermission(android.permission.CHANGE_WIFI_STATE)
 
Upvote 0
Top