Running/Start time of android application/process?

by vishnu kumarraju » Sat, 12 Feb 2011 05:51:09 GMT


Sponsored Links
 I'm new to android,  my requirement is to display active process
running with process start time.
I'm able to get the list of running process name/ID's with the below
code, but couldn't able to find how long process is running.

Here is my code sample.


                List l = activityManager.getRunningAppProcesses();
                        Iterator i = l.iterator();
                PackageManager pm = this.getPackageManager();

while(i.hasNext()) {
                  ActivityManager.RunningAppProcessInfo info =
(ActivityManager.RunningAppProcessInfo)(i.next());
                  try {
                    CharSequence c =
pm.getApplicationLabel(pm.getApplicationInfo(info.processName,
PackageManager.GET_META_DATA));
                    Log.w("LABEL :::", c.toString());

                  }catch(Exception e) {
                    //Name Not FOund Exception
                  }


Can you suggest me is there any class I need to look into it?  It
would be great help if some one can help me with sample code. Thanks
in Advance.

Thanks & Regards
Vishnu.K

-- 



Other Threads

1. ItemizedOverlay Issue

I searched the groups, but the suggestions/fixes I've seen don't seem
to work.

I tried to simplify this to the least amount of code, and there are
three classes: MapsActivity, MyItemizedOverlay (to contain overlay
items), and CustomDrawable (used by the overlay item).

When I "restore" the canvas inside the custom drawable, it seems to
put the circle in the correct location.

When I use a default drawable (i.e. the icon) everything works, and
the canvas restore is not needed.

Here is the code:

=======================================================================
public class MapsActivity extends MapActivity
{
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapView = (MapView) findViewById(R.id.mapView);
        mapView.setBuiltInZoomControls(true);

        // Itemized Overlay
        List<Overlay> mapOverlays = mapView.getOverlays();
        Drawable defaultIcon =
this.getResources().getDrawable(R.drawable.icon);
        MyItemizedOverlay itemizedoverlay = new
MyItemizedOverlay(defaultIcon, this);

        // Overlay Item
        GeoPoint pt = new GeoPoint(30000000, -90000000);
        OverlayItem item = new OverlayItem(pt,"New Orleans",
"Louisiana");

        // Custom Drawable
        CustomDrawable customDrawable = new CustomDrawable(pt,
mapView);

        boolean showProblem = true;
        if (showProblem)
        {
            item.setMarker(customDrawable);
        }
        else
        {
            item.setMarker(defaultIcon);
        }

        // Add item we want to overlay
        itemizedoverlay.addOverlay(item);

        // Add overlay
        mapOverlays.add(itemizedoverlay);
    }

    protected boolean isRouteDisplayed()
    {
        return false;
    }
}
=======================================================================
public class MyItemizedOverlay extends ItemizedOverlay<OverlayItem>
{
    private ArrayList<OverlayItem> mOverlays = new
ArrayList<OverlayItem>();

    private Context mContext;

    public MyItemizedOverlay(Drawable defaultMarker, Context context)
    {
        super(boundCenterBottom(defaultMarker));
        mContext = context;
    }

    public void addOverlay(OverlayItem item)
    {
        mOverlays.add(item);
        populate();
    }

    public void removeOverlay(OverlayItem item)
    {
        mOverlays.remove(item);
    }

    public void removeOverlay(int item)
    {
        mOverlays.remove(item);
    }

    protected OverlayItem createItem(int i)
    {
        OverlayItem item = mOverlays.get(i);
        Drawable drawable = item.getMarker(0);

        if (drawable != null)
        {
            int w = drawable.getIntrinsicWidth();
            int h = drawable.getIntrinsicHeight();

            drawable.setBounds(0, 0, w, h);

            item.setMarker(boundCenterBottom(drawable));
        }

        return item;
    }

    public void draw(android.graphics.Canvas canvas, MapView mapView,
            boolean shadow)
    {
        if (shadow)
            return;

        super.draw(canvas, mapView, shadow);
    }

    public int size()
    {
        return mOverlays.size();
    }

    protected boolean onTap(int index)
    {
        OverlayItem item = mOverlays.get(index);
        AlertDialog.Builder dialog = new
AlertDialog.Builder(mContext);
        dialog.setTitle(item.getTitle());
        dialog.setMessage(item.getSnippet());
        dialog.show();

        return true;
    }
}

=======================================================================
public class CustomDrawable extends ShapeDrawable
{
    private int radius = 10;
    private GeoPoint point = null;
    private MapView mapView = null;

    public CustomDrawable(GeoPoint point, MapView mapView)
    {
        this.point  = point;
        this.mapView  = mapView;
    }

    public void draw(Canvas canvas)
    {
        // TODO This (somewhat) fixes projection problem?
        //canvas.restore();

        Projection projection = mapView.getProjection();

        Point pt = projection.toPixels(point, null);

        canvas.drawCircle(pt.x, pt.y, radius,
getPaint());
    }

    public int getIntrinsicHeight()
    {
        return 2 * radius;
    }

    public int getIntrinsicWidth()
    {
        return 2 * radius;
    }
}
=======================================================================

Any help would be greatly appreciated.



-- 

2. possible to track movement without GPS

Hi

Is it possible to track movement without GPS?  The GPS signal is too
weak on my phone to work indoors.  I want to be able to track where
I've been within a building.  Possible?

Tks

-- 

3. Handler still runs after thread it's attached to is destroyed

4. ListView of CheckedTextView + SQLite, display checked rows ?

5. Map key: Overlays shown but not Map when using Generated key

6. Careful, Dell Streak 7 ignores manifest setting for Orientation

7. Ask the urgent problem of the project: call number for do not know why not?