B4A Library OS Library

Hello everyone,

I present you thé OS Lib. aka. the Operating System Library.:sign0025:
This 'giant' library has around 60+ commands.
Everything is explained in the library itself.

What does it cover:

- Memory size of directories
- Tons of hardware strings (e.g model, device, host, ...)
- A unique, very easy countdown timer with 2 events (easier than timer :sign0103:

B4X:
Dim OS As OperatingSystem
OS.Initialize("OS")
OS.CountDownTimer(1000)

Sub OS_ontick (ms as long)
       toastmessageshow(ms,false)
end sub

Sub OS_onfinish (OS As String)
   Msgbox(OS,"OS Library") 'get the secret message in here ;)
End Sub

- CPU information
- Running services, tasks, sending signals
- Rebooting (and wiping data)
- and a lot more!

Note that it is still in beta and errors may still occur. ( I haven't tested all functions yet.)
Please tell it here when, why, what, etc happened.
It is also possible that I didn't add a certain permission as I can't find them always.

I like feedback as it gives me more motivation. :D
(now go and make your own task killer :^))


Cheerz!
Tomas
 

Attachments

  • OSLibraryV13.zip
    18.3 KB · Views: 1,624
  • OSLibrary1.4.zip
    13.9 KB · Views: 3,438
Last edited:

GMan

Well-Known Member
Licensed User
Is there any brief description of the library without browsing the lib itself with an XML-Editor ?
 

cncncn

Member
Licensed User
Hi,

I want to kill adobe reader so i get PID of Adobe then i use this :
B4X:
Dim closeadobe as OperatingSystem
closeadobe.killprocess(144287)

Is there any special permissions beacause it doesn't works
 

GMan

Well-Known Member
Licensed User
Killing other processes doesn't work on most devices.
And thats the reason why most of the "Task Managers" dont work at the Point: Clean or Kill process
 

westingenieria

Active Member
Licensed User
Thanks a lot Erel!
Here's some example code:
B4X:
Msgbox(OS.AvailableExternalMemorySize,OS.AvailableInternalMemorySize)
Msgbox(OS.AvailableMemory,OS.Board)
Msgbox(OS.CPUABI,OS.Host)
Msgbox(OS.myPid,OS.myTid)
Msgbox(OS.RunningAppProcesses,"Processes")
Msgbox(OS.ReadCPUinfo,"Processes")
Msgbox(OS.RunningAppProcess,OS.Time)
Msgbox(OS.formatSize(256),"FormatSize")

Msgbox(OS.getRunningServices(10),"Running Services")
Msgbox(OS.getRunningTasks(10),"Running Tasks")
OS.killProcess(OS.myPid)
It works, however, I still have a question:

Using this:

B4X:
Msgbox(OS.RunningAppProcesses,"Processes")

I receive the following information:



How can I 'interpretate' this?
Is it possible to get names, etc out of it?

Thanks

XverhelstX


hi, Is it possible to get names, etc out of it?
B4X:
os.RunningAppProcesses()
...
how?
 

Baltazar

Member
Licensed User
Updated to 1.4.
I hope this is what you are after Cableguy.

Includes:

- density: The logical density of the display.
- densityDpi: The screen density expressed as dots-per-inch.
- heightPixels: The absolute height of the display in pixels.
- scaledDensity: A scaling factor for fonts displayed on the display.
- widthPixels: The absolute width of the display in pixels.
- xdpi :The exact physical pixels per inch of the screen in the X dimension.
- ydpi :The exact physical pixels per inch of the screen in the Y dimension.

I also added physicalScreenWidth and physicalScreenHeight.
= xdpi * widthPixels and ydpi * heightPixels.

Tomas
Fantastic work XverhelstX ! These were just the ones I was about to ask. :D:p. Thank you!
 

boralogy

Member
Licensed User
can't get battery level could you help me? it returns NULL
B4X:
Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
Dim ag As OperatingSystem
    Private bat_lvl As Label
    Private Label1 As Label
   
End Sub

Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("low_main")
   
bat_lvl.Text=ag.BatteryLevel




End Sub
 

wonder

Expert
Licensed User
Hello!

B4X:
Error serving request: (SecurityException) java.lang.SecurityException: Neither user 10165 nor current process has android.permission.REBOOT.
Adding the permission "android.permission.REBOOT" doesn't solve it.
How can I reboot? The device is rooted, by the way.
 

BarryW

Active Member
Licensed User
Hello everyone,

I present you thé OS Lib. aka. the Operating System Library.:sign0025:
This 'giant' library has around 60+ commands.
Everything is explained in the library itself.

What does it cover:

- Memory size of directories
- Tons of hardware strings (e.g model, device, host, ...)
- A unique, very easy countdown timer with 2 events (easier than timer :sign0103:

B4X:
Dim OS As OperatingSystem
OS.Initialize("OS")
OS.CountDownTimer(1000)

Sub OS_ontick (ms as long)
       toastmessageshow(ms,false)
end sub

Sub OS_onfinish (OS As String)
   Msgbox(OS,"OS Library") 'get the secret message in here ;)
End Sub

- CPU information
- Running services, tasks, sending signals
- Rebooting (and wiping data)
- and a lot more!

Note that it is still in beta and errors may still occur. ( I haven't tested all functions yet.)
Please tell it here when, why, what, etc happened.
It is also possible that I didn't add a certain permission as I can't find them always.

I like feedback as it gives me more motivation. :D
(now go and make your own task killer :^))


Cheerz!
Tomas

Hi!

i try to use

B4X:
Dim OS As OperatingSystem : OS.Initialize("OS")
Dim ProcessName, PIDs, NamePIDs, RunningApps As List
ProcessName.Initialize : PIDs.Initialize : NamePIDs.Initialize : RunningApps.Initialize
RunningApps = OS.RunningAppProcessInfo(ProcessName, PIDs, NamePIDs)

Can we turn off the logs of process list... Tnx
 
Top