[android-developers] Re: process ids

2008-10-27 Thread alexdonnini

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 ArrayListString();
             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);
         ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: process ids

2008-10-27 Thread Ludwig
Thanks, that is quite a bit more elegant than what I proposed.
(Hint to Google: the documentation for the clear() method on the
SharedPreferences.Editor says:
Mark in the editor to remove *all* values from the preferences. Once commit
is called, the only remaining preferences will be any that you have defined
in this editor.
That is, IMHO, not exactly the same as saying that everything will be reset
to what is defined in the XML file... I would have assumed that by just
calling clear() it would result in all queries to the shared preferences
settings then returning that they are not set.)

Ludwig


2008/10/27 alexdonnini [EMAIL PROTECTED]


 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 ArrayListString();
  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);
  ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: process ids

2008-10-27 Thread Ludwig
Sorry that was posted on the wrong thread.

2008/10/27 Ludwig [EMAIL PROTECTED]

 Thanks, that is quite a bit more elegant than what I proposed.
 (Hint to Google: the documentation for the clear() method on the
 SharedPreferences.Editor says:
 Mark in the editor to remove *all* values from the preferences. Once
 commit is called, the only remaining preferences will be any that you have
 defined in this editor.
 That is, IMHO, not exactly the same as saying that everything will be reset
 to what is defined in the XML file... I would have assumed that by just
 calling clear() it would result in all queries to the shared preferences
 settings then returning that they are not set.)

 Ludwig


 2008/10/27 alexdonnini [EMAIL PROTECTED]


 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 ArrayListString();
  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);
  ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: process ids

2008-10-26 Thread alexdonnini

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);
          ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: process ids

2008-10-26 Thread alexdonnini

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 ArrayListString();
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);
           ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: process ids

2008-10-26 Thread Ludwig
/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 ArrayListString();
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);
ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---



[android-developers] Re: process ids

2008-10-23 Thread hackbod

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);
         ListActivityManager.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 android-developers@googlegroups.com
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
-~--~~~~--~~--~--~---