Ludwig,
Thanks. I was aware of the /proc structure. ps gets its data from /
proc/stats
I thought that using ps would minimize the possibility of future
incompatibilities.
when running the code I listed below, it does not fail. However, all
it seems to retrieve is the column headers.
Note that when I run the code on a Linux desktop (via Eclipse). The
expected output, the entrie list of processes, is produced.
So, at this point, I wonder why when running the code in the Android
emulator, all I get is the column headers.
Alex
On Oct 26, 5:54 pm, Ludwig <[EMAIL PROTECTED]> wrote:
> /proc is a (virtual) file system, so you can navigate through it with the
> usual File operations. For every process there is a directory /proc/pid
> where pid is the processes PID. Under that directory is a whole lot of stuff
> relating to that process, such as command line, actual executable, open
> files etc etc.
> Searching for proc filesystem should give you much more information, but as
> hackbod pointed out you do not have any guarantees that the layout will stay
> exactly the same over versions/devices etc.Command like ps actually read
> from /proc for their output.
>
> Ludwig
>
> 2008/10/26 alexdonnini <[EMAIL PROTECTED]>
>
>
>
> > I thought I would try using ps with code like the one listed below.
> > headers for the process list are reported correctly but not much else.
>
> > When you mentioned accessing /proc directly, did you have something
> > else (other than ps) in mind?
>
> > Thanks.
>
> > Alex Donnini
>
> > private void getProcessList()
> > {
> > System.out.println("retrieving list of running processes via --
> > ps -e -- command");
> > try
> > {
> > processList = new ArrayList<String>();
> > String line;
> > java.lang.Process p = Runtime.getRuntime().exec("ps -e");
> > BufferedReader input =
> > new BufferedReader(new
> > InputStreamReader(p.getInputStream()));
> > while ((line = input.readLine()) != null)
> > {
> > System.out.println("running process - "+line); //<--
> > Parse data here.
> > processList.add(line);
> > }
> > input.close();
> > }
> > catch (Exception err)
> > {
> > err.printStackTrace();
> > }
>
> > On Oct 26, 2:43 pm, alexdonnini <[EMAIL PROTECTED]> wrote:
> > > Thanks. I understand the risk in going for direct access.
>
> > > On Oct 24, 1:09 am, hackbod <[EMAIL PROTECTED]> wrote:
>
> > > > Sorry, we don't currently have a high-level API for doing this. As a
> > > > hack, you can read /proc directly, but that is not something that is
> > > > part of the SDK and so you have no guarantees of it working on future
> > > > releases or other phones.
>
> > > > On Oct 23, 8:25 pm,alexdonnini<[EMAIL PROTECTED]> wrote:
>
> > > > > Hello,
>
> > > > > Would anyone be able to tell me (or point me in the right direction)
> > > > > how I could retrieve the pids and related process information as
> > > > > reported, for example, in DDMS in an Android application?
>
> > > > > I have been able to put together a small application that retrieves
> > > > > information about all tasks running
> > > > > (ActivityManager activityManager =
> > > > > (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
> > > > > List<ActivityManager.RunningTaskInfo> runningTasks =
> > > > > activityManager.getRunningTasks(30); )
>
> > > > > However, if possible, I would like to retrieve task and process
> > > > > information at a higher level of granularity (or, if you like, at
> > > > > lower level).
>
> > > > > Any help would be greatly appreciated.
>
> > > > > Thanks.
>
> > > > > Alex Donnini
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---