B4A Library OS Library

rfresh

Well-Known Member
Licensed User
Longtime User
Thank you for writing the OS library.

I have a couple of questions.

I looked at the .xml file and saw the info on reboot but when I use the code

B4X:
OS.reboot

It says there is a missing parameter?
 

kanaida

Active Member
Licensed User
Longtime User

You can reboot the phone without a library using a shell command...
I don't think it requires root. It's what I use in my own apps.
B4X:
Dim p As phone
p.Shell("reboot",Null,Null,Null)
 

rfresh

Well-Known Member
Licensed User
Longtime User
B4X:
Dim p As phone
p.Shell("reboot",Null,Null,Null)

Did not work on my Droid2...perhaps it does require your phone to be rooted?
 

marcomilazzo

Member
Licensed User
Longtime User
reboot

Hi
what did you write to get the reboot privileges
i tried with:
os.reboot( "-p")
p should be a parameter to shut down !! i hope
and after i get the error of no priv..

thank's
marco
 

rfresh

Well-Known Member
Licensed User
Longtime User
I tried it with the "-p" argument and I got an err msg saying I don't have reboot permission. I added a .REBOOT line to my manifest but I still got the you don't have reboot permission error messge.
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
After some testing it's not possible to reboot the device.
I also keep having the same reboot error, though the permission is added.

Here's some more information:
Programmatically switching off Android phone - Stack Overflow

This is the java code i use:
B4X:
/**
        * Reboot the device. Will not return if the reboot is successful. 
        * reason   code to pass to the kernel (e.g., "recovery") to request special boot modes, or null.
        * Api level 8
        */
     public void reboot(String Reason) {
        PowerManager pm = (PowerManager)BA.applicationContext.getSystemService(ba.applicationContext.POWER_SERVICE);   
        pm.reboot(Reason);
     }

Kind regards,
Tomas
 

vb1992

Well-Known Member
Licensed User
Longtime User
you might be able to do it with an intent

Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(intent);
 

rfresh

Well-Known Member
Licensed User
Longtime User
I tried compiling your code below but the new keyword is causing an error and shows in the IDE in red.

Error: Error description: Input string was not in a correct format.

B4X:
Dim mContext As Int
   
Intent Intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
Intent.putExtra(Intent.EXTRA_KEY_CONFIRM, False);
Intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
mContext.startActivity(Intent);
 

arp

Member
Licensed User
Longtime User
OSLibrary Bug

Hi,

Very nice library, thanks.

It seems the RunningAppProcessInfo function populates both List1 and List3 with the same information, that being the package name and the pid. Instead of List one just containing the package name

Regards
 

peacemaker

Expert
Licensed User
Longtime User
1) How exactly works installPackage? What needs for working ?
2) How practically to make java.io.file argument for it ?
3) Is maybe DeletePackage also possible ?
 

mjtaryan

Active Member
Licensed User
Longtime User
It should be in bytes:

StatFs | Android Developers

and thanks,

XverhelstX

Would be helpful if your refined the numbers so they
1. presented in appropriate groupings (i.e. bytes if less than 1,000; kb 1,000 - 1,000,000; mb 1 million to 1 billion; gb 1 billion and above).
2. displays rounded mb and gb values to neaest hundreth (i.e. 1.67gb)
3. have the option for displaying actual (non-rounded) values for mb and gb.

Just a thought.

BTW -- what version of the library are you on now?
 

aloof

Member
Licensed User
Longtime User
can we get an example of OS.RunningAppProcessInfo OS.RunningAppProcesses

say putting the list into a label or checkboxes,i find the info a little confusing thanks
 

imgsimonebiliato

Well-Known Member
Licensed User
Longtime User
Many thanks for your useful library! :icon_clap:
 

tc.goethe

Member
Licensed User
Longtime User
Thanks for the OS.Library, but I have a problem to read the activity.title of other apps.

This will not do. I only get the activity. Not the title ....


B4X:
   Dim OS As OperatingSystem
    
   Dim Tasks As List    
   Tasks = OS.getRunningTasks(1000)
   If Tasks.Size > 0 Then        
   For i = 0 To Tasks.Size - 1            
   Dim r As Reflector
   r.Target = Tasks.Get(i)
   Log(r.GetField("topActivity"))
   Log(r.GetField("baseActivity"))
   Next    
   End If

Can anyone help me?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…