FileDocCategorySizeDatePackage
ActivityLaunchAction.javaAPI DocAndroid 1.5 API3587Wed May 06 22:41:10 BST 2009com.android.ide.eclipse.adt.launch

ActivityLaunchAction

public class ActivityLaunchAction extends Object implements IAndroidLaunchAction
Launches the given activity

Fields Summary
private final String
mActivity
private final ILaunchController
mLaunchController
Constructors Summary
public ActivityLaunchAction(String activity, ILaunchController controller)
Creates a ActivityLaunchAction

param
activity fully qualified activity name to launch
param
controller the {@link ILaunchController} that performs launch

        mActivity = activity;
        mLaunchController = controller;
    
Methods Summary
public booleandoLaunchAction(DelayedLaunchInfo info, com.android.ddmlib.IDevice device)
Launches the activity on targeted device

param
info the {@link DelayedLaunchInfo} that contains launch details
param
device the Android device to perform action on
see
IAndroidLaunchAction#doLaunchAction(DelayedLaunchInfo, IDevice)

        try {
            String msg = String.format("Starting activity %1$s on device ", mActivity,
                    device);
            AdtPlugin.printToConsole(info.getProject(), msg);

            // In debug mode, we need to add the info to the list of application monitoring
            // client changes.
            // increment launch attempt count, to handle retries and timeouts
            info.incrementAttemptCount();

            // now we actually launch the app.
            device.executeShellCommand("am start" //$NON-NLS-1$
                    + (info.isDebugMode() ? " -D" //$NON-NLS-1$
                            : "") //$NON-NLS-1$
                    + " -n " //$NON-NLS-1$
                    + info.getPackageName() + "/" //$NON-NLS-1$
                    + mActivity.replaceAll("\\$", "\\\\\\$"), //$NON-NLS-1$ //$NON-NLS-2$
                    new AMReceiver(info, device, mLaunchController));

            // if the app is not a debug app, we need to do some clean up, as
            // the process is done!
            if (info.isDebugMode() == false) {
                // stop the launch object, since there's no debug, and it can't
                // provide any control over the app
                return false;
            }
        } catch (IOException e) {
            // something went wrong trying to launch the app.
            // lets stop the Launch
            AdtPlugin.printErrorToConsole(info.getProject(),
                    String.format("Launch error: %s", e.getMessage()));
            return false;
        }
        return true;
    
public java.lang.StringgetLaunchDescription()
Returns a description of the activity being launched

see
IAndroidLaunchAction#getLaunchDescription()

       return String.format("%1$s activity launch", mActivity);