FileDocCategorySizeDatePackage
AliasActivity.javaAPI DocAndroid 1.5 API4514Wed May 06 22:41:54 BST 2009android.app

AliasActivity

public class AliasActivity extends Activity
Stub activity that launches another activity (and then finishes itself) based on information in its component's manifest meta-data. This is a simple way to implement an alias-like mechanism. To use this activity, you should include in the manifest for the associated component an entry named "android.app.alias". It is a reference to an XML resource describing an intent that launches the real application.

Fields Summary
public final String
ALIAS_META_DATA
This is the name under which you should store in your component the meta-data information about the alias. It is a reference to an XML resource describing an intent that launches the real application. {@hide}
Constructors Summary
Methods Summary
protected voidonCreate(android.os.Bundle savedInstanceState)

    
    
        
        super.onCreate(savedInstanceState);
        
        XmlResourceParser parser = null;
        try {
            ActivityInfo ai = getPackageManager().getActivityInfo(
                    getComponentName(), PackageManager.GET_META_DATA);
            parser = ai.loadXmlMetaData(getPackageManager(),
                    ALIAS_META_DATA);
            if (parser == null) {
                throw new RuntimeException("Alias requires a meta-data field "
                        + ALIAS_META_DATA);
            }
            
            Intent intent = parseAlias(parser);
            if (intent == null) {
                throw new RuntimeException(
                        "No <intent> tag found in alias description");
            }
            
            startActivity(intent);
            finish();
            
        } catch (PackageManager.NameNotFoundException e) {
            throw new RuntimeException("Error parsing alias", e);
        } catch (XmlPullParserException e) {
            throw new RuntimeException("Error parsing alias", e);
        } catch (IOException e) {
            throw new RuntimeException("Error parsing alias", e);
        } finally {
            if (parser != null) parser.close();
        }
    
private android.content.IntentparseAlias(org.xmlpull.v1.XmlPullParser parser)

        AttributeSet attrs = Xml.asAttributeSet(parser);
        
        Intent intent = null;
        
        int type;
        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
                && type != XmlPullParser.START_TAG) {
        }
        
        String nodeName = parser.getName();
        if (!"alias".equals(nodeName)) {
            throw new RuntimeException(
                    "Alias meta-data must start with <alias> tag; found"
                    + nodeName + " at " + parser.getPositionDescription());
        }
        
        int outerDepth = parser.getDepth();
        while ((type=parser.next()) != XmlPullParser.END_DOCUMENT
               && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) {
            if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) {
                continue;
            }

            nodeName = parser.getName();
            if ("intent".equals(nodeName)) {
                Intent gotIntent = Intent.parseIntent(getResources(), parser, attrs);
                if (intent == null) intent = gotIntent;
            } else {
                XmlUtils.skipCurrentTag(parser);
            }
        }
        
        return intent;