Android : HOST END : ddmlib : How do I get the Apps running on device via ddmlib.jar
<pre><code>package com.android.ddmlib.use;

import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.Client;
import com.android.ddmlib.IDevice;
import com.android.hierarchyviewer.device.DeviceBridge;

public class DDMlibUse implements AndroidDebugBridge.IDeviceChangeListener, AndroidDebugBridge.IClientChangeListener{

 public static void main(String args[]) {

       DDMlibUse mlibUse = new DDMlibUse();

       AndroidDebugBridge.init(true);
       AndroidDebugBridge adb = AndroidDebugBridge.createBridge("adb",
                                false);
       adb.addClientChangeListener(mlibUse);
       adb.addDeviceChangeListener(mlibUse);
       for (;;) {

       }
 }

@Override
public void deviceConnected(IDevice dev) {
    // TODO Auto-generated method stub
    System.out.print("deviceConnected ... \n");
    System.out.print(dev.toString() + "\n");
    System.out.print(dev.getState() + "\n");
    System.out.println(dev.getClients().length);

}

@Override
public void deviceDisconnected(IDevice dev) {
    // TODO Auto-generated method stub
    System.out.print("deviceDisconnected ... \n");
    DeviceBridge.removeDeviceForward(dev);

}

@Override
public void deviceChanged(IDevice dev, int changeMask) {
    // TODO Auto-generated method stub
    System.out.print("deviceChanged ... \n");
    System.out.print(dev.toString() + "\n");
    System.out.print(dev.getState() + "\n");
    System.out.println(dev.getClients().length + "\n");
    System.out.println("changeMask " + changeMask + "\n");

}

@Override
public void clientChanged(Client client, int change_code) {
    // TODO Auto-generated method stub
    System.out.print("clientChanged ... \n");

}

}
</code></pre>

<p>The result is the Device is ON_LINE but calling getClients method only returns a array[0] of Client. I can't get any Client
And another thing is when I launch a new App on device, I will never get "changeMask" to be IDevice.CHANGE_CLIENT_LIST </p>

<p>Can you help me ? thx a lot
My purpose is to get which Activity on device is in front just like what Hierarchyviewer and DDMS do.</p>
