It seems that you people are sleeping!!!!!!
On Feb 25, 7:47 am, Dianne Hackborn <hack...@android.com> wrote:
> Fwiw, this is soooooooo not something you should do in a normal app. Going
> it getting a list of running apps, arbitrarily bounded to 100, is a big clue
> of this.
>
> And in general, there is no one single package name associated with a pid.
> You really shouldn't be dealing with pids; the identity of most everything
> is based on its uid, and the pid is fairly irrelevent. (Not that a uid
> necessarily has a single package name associated with it either.)
>
>
>
> On Tue, Feb 24, 2009 at 3:41 PM, sm1 <sergemas...@gmail.com> wrote:
>
> > In free app *Device Internals for r1*, I get the running services this
> > way:
>
> > StringBuffer getRunningServices(ActivityManager am){
> > StringBuffer buf = new StringBuffer();
> > buf.append("\n\nRunning Services:");
> > List<ActivityManager.RunningServiceInfo> list = null;
> > try{
> > list = am.getRunningServices(100);
> > }catch(Throwable ex){
> > buf.append("\n "+ex);
> > return buf;
> > }
> > if(list.isEmpty()){
> > buf.append(" None listed.");
> > return buf;
> > }
> > int i = 1;
> > for(ActivityManager.RunningServiceInfo info: list){
> > buf.append("\n ["+i+"] pid {"+info.pid+"}:");
> > buf.append("\n foreground {"+info.foreground+"}");
> > buf.append("\n active since {"+info.activeSince+"} millis =
> > "+millisToSignHhMmSs(info.activeSince)+" "+HMS);
> > buf.append("\n last activity time {"+info.lastActivityTime+"}
> > millis = "+millisToSignHhMmSs(info.lastActivityTime)+" "+HMS);
> > buf.append("\n client count {"+info.clientCount+"}");
> > buf.append("\n crash count {"+info.crashCount+"}");
> > buf.append("\n service class {"+info.service.getClassName()
> > +"}");
> > buf.append("\n process {"+info.process+"}");
> > if(info.restarting==0){
> > buf.append("\n restarting at {"+info.restarting+"} zero means
> > not scheduled to restart");
> > }else{
> > buf.append("\n restarting at {"+info.restarting+"} millis =
> > "+millisToSignHhMmSs(info.restarting)+" "+HMS);
> > }
> > buf.append("\n started {"+info.started+"}");
> > //buf.append("\n toString {"+info.toString()+"}");
> > ++i;
> > }
> > return buf;
> > }
>
> > And this will get you one process name if you know the Pid:
>
> > /** @return null when givenPid not found in list of 100 first
> > services. */
> > String getProcessNameFromPid(int givenPid){
> > ActivityManager am = (ActivityManager) getSystemService
> > (Context.ACTIVITY_SERVICE);
> > List<ActivityManager.RunningServiceInfo> list =
> > am.getRunningServices(100);
> > for(ActivityManager.RunningServiceInfo info: list){
> > if(info.pid == givenPid){
> > return info.process;
> > }
> > }
> > return null;
> > }
>
> > cheers,
> > serge
>
> > On Feb 24, 4:23 am, sohail khan <sohail.k...@imsciences.edu.pk> wrote:
> > > Hi all,
>
> > > How do I get the Package Name if I am having the PID of the process. For
> > > example, if I want to output a list of currently
> > > running processes, I can get the PIDs but how do I get the names of the
> > > PIDs?
>
> > > Thanks.
> > > --
> > > sohail
>
> --
> Dianne Hackborn
> Android framework engineer
> hack...@android.com
>
> Note: please don't send private questions to me, as I don't have time to
> provide private support. All such questions should be posted on public
> forums, where I and others can see and answer them.
--~--~---------~--~----~------------~-------~--~----~
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
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---