FileDocCategorySizeDatePackage
Main.javaAPI DocAndroid 1.5 API3527Wed May 06 22:41:08 BST 2009com.android.ddms

Main

public class Main extends Object
Start the UI and network.

Fields Summary
public static final String
VERSION
User visible version number.
Constructors Summary
public Main()


      
    
Methods Summary
public static voidmain(java.lang.String[] args)
Parse args, start threads.

        // In order to have the AWT/SWT bridge work on Leopard, we do this little hack.
        String os = System.getProperty("os.name"); //$NON-NLS-1$
        if (os.startsWith("Mac OS")) { //$NON-NLS-1$
            RuntimeMXBean rt = ManagementFactory.getRuntimeMXBean();
            System.setProperty(
                    "JAVA_STARTED_ON_FIRST_THREAD_" + (rt.getName().split("@"))[0], //$NON-NLS-1$
                    "1"); //$NON-NLS-1$
        }
        
        Thread.setDefaultUncaughtExceptionHandler(new UncaughtHandler());

        // load prefs and init the default values
        PrefsDialog.init();

        Log.d("ddms", "Initializing");

        // the "ping" argument means to check in with the server and exit
        // the application name and version number must also be supplied
        if (args.length >= 3 && args[0].equals("ping")) {
            SdkStatsService.ping(args[1], args[2]);
            return;
        } else if (args.length > 0) {
            Log.e("ddms", "Unknown argument: " + args[0]);
            System.exit(1);
        }

        // ddms itself is wanted: send a ping for ourselves
        SdkStatsService.ping("ddms", VERSION);  //$NON-NLS-1$

        DebugPortManager.setProvider(DebugPortProvider.getInstance());

        // create the three main threads
        UIThread ui = UIThread.getInstance();

        try {
            ui.runUI();
        } finally {
            PrefsDialog.save();
    
            AndroidDebugBridge.terminate();
        }

        Log.d("ddms", "Bye");
        
        // this is kinda bad, but on MacOS the shutdown doesn't seem to finish because of
        // a thread called AWT-Shutdown. This will help while I track this down.
        System.exit(0);