src/main/java/com/simpligility/maven/plugins/android/standalonemojos/RunMojo.java
private LauncherInfo getLauncherActivity()
            throws ParserConfigurationException, SAXException, IOException, XPathExpressionException,
            MojoFailureException
    {
        Document document;
        DocumentBuilder documentBuilder;
        DocumentBuilderFactory documentBuilderFactory;
        Object result;
        XPath xPath;
        XPathExpression xPathExpression;
        XPathFactory xPathFactory;

        //
        // Setup JAXP stuff
        //
        documentBuilderFactory = DocumentBuilderFactory.newInstance();

        documentBuilder = documentBuilderFactory.newDocumentBuilder();

        document = documentBuilder.parse( destinationManifestFile );

        xPathFactory = XPathFactory.newInstance();

        xPath = xPathFactory.newXPath();

        xPathExpression = xPath.compile(
                "//manifest/application/activity/intent-filter[action[@name=\"android.intent.action.MAIN\"] "
                + "and category[@name=\"android.intent.category.LAUNCHER\"]]/.." );

        //
        // Run XPath query
        //
        result = xPathExpression.evaluate( document, XPathConstants.NODESET );

        if ( result instanceof NodeList )
        {
            NodeList activities;

            activities = ( NodeList ) result;

            if ( activities.getLength() > 0 )
            {
                // Grab the first declared Activity
                LauncherInfo launcherInfo;

                launcherInfo = new LauncherInfo();
                String activityName = activities.item( 0 ).getAttributes().getNamedItem( "android:name" )
                        .getNodeValue();

                if ( ! activityName.contains( "." ) )
                {
                    activityName = "." + activityName;
                }

                if ( activityName.startsWith( "." ) )
                {
                    String packageName = document.getElementsByTagName( "manifest" ).item( 0 ).getAttributes()
                            .getNamedItem( "package" ).getNodeValue();
                    activityName = packageName + activityName;
                }

                launcherInfo.activity = activityName;

                launcherInfo.packageName = renameManifestPackage != null
                    ? renameManifestPackage
                    : document.getDocumentElement().getAttribute( "package" ).toString();

                return launcherInfo;
            }
            else
            {
                // If we get here, we couldn't find a launcher activity.
                throw new MojoFailureException( "Could not find a launcher activity in manifest" );
            }
        }
        else
        {
            // If we get here we couldn't find any Activity
            throw new MojoFailureException( "Could not find any activity in manifest" );
        }
    }
private LauncherInfo getLauncherActivity()
            throws ParserConfigurationException, SAXException, IOException, XPathExpressionException,
            MojoFailureException
    {
        Document document;
        DocumentBuilder documentBuilder;
        DocumentBuilderFactory documentBuilderFactory;
        Object result;
        XPath xPath;
        XPathExpression xPathExpression;
        XPathFactory xPathFactory;

        //
        // Setup JAXP stuff
        //
        documentBuilderFactory = DocumentBuilderFactory.newInstance();

        documentBuilder = documentBuilderFactory.newDocumentBuilder();

        document = documentBuilder.parse( destinationManifestFile );

        xPathFactory = XPathFactory.newInstance();

        xPath = xPathFactory.newXPath();

        xPathExpression = xPath.compile(
                "//manifest/application/activity/intent-filter[action[@name=\"android.intent.action.MAIN\"] "
                + "and category[@name=\"android.intent.category.LAUNCHER\"]]/.." );

        //
        // Run XPath query
        //
        result = xPathExpression.evaluate( document, XPathConstants.NODESET );

        if ( result instanceof NodeList )
        {
            NodeList activities;

            activities = ( NodeList ) result;

            if ( activities.getLength() > 0 )
            {
                // Grab the first declared Activity
                LauncherInfo launcherInfo;

                launcherInfo = new LauncherInfo();
                String activityName = activities.item( 0 ).getAttributes().getNamedItem( "android:name" )
                        .getNodeValue();

                if ( ! activityName.contains( "." ) )
                {
                    activityName = "." + activityName;
                }

                if ( activityName.startsWith( "." ) )
                {
                    String packageName = document.getElementsByTagName( "manifest" ).item( 0 ).getAttributes()
                            .getNamedItem( "package" ).getNodeValue();
                    activityName = packageName + activityName;
                }

                launcherInfo.activity = activityName;

                launcherInfo.packageName = renameManifestPackage != null
                    ? renameManifestPackage
                    : document.getDocumentElement().getAttribute( "package" ).toString();

                return launcherInfo;
            }
            else
            {
                // If we get here, we couldn't find a launcher activity.
                throw new MojoFailureException( "Could not find a launcher activity in manifest" );
            }
        }
        else
        {
            // If we get here we couldn't find any Activity
            throw new MojoFailureException( "Could not find any activity in manifest" );
        }
    }
Gets the first "Launcher" Activity by running an XPath query on <code>AndroidManifest.xml</code>.

@return A {@link LauncherInfo}
@throws MojoFailureException
@throws ParserConfigurationException
@throws IOException
@throws SAXException
@throws XPathExpressionException