summaryrefslogtreecommitdiff
path: root/core/java/android/app/AliasActivity.java
diff options
context:
space:
mode:
authorThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:45 -0800
committerThe Android Open Source Project <initial-contribution@android.com>2009-03-03 18:28:45 -0800
commitd83a98f4ce9cfa908f5c54bbd70f03eec07e7553 (patch)
tree4b825dc642cb6eb9a060e54bf8d69288fbee4904 /core/java/android/app/AliasActivity.java
parent076357b8567458d4b6dfdcf839ef751634cd2bfb (diff)
auto import from //depot/cupcake/@135843
Diffstat (limited to 'core/java/android/app/AliasActivity.java')
-rw-r--r--core/java/android/app/AliasActivity.java123
1 files changed, 0 insertions, 123 deletions
diff --git a/core/java/android/app/AliasActivity.java b/core/java/android/app/AliasActivity.java
deleted file mode 100644
index 4f91e020ce38..000000000000
--- a/core/java/android/app/AliasActivity.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2007 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package android.app;
-
-import org.xmlpull.v1.XmlPullParser;
-import org.xmlpull.v1.XmlPullParserException;
-
-import android.content.Intent;
-import android.content.pm.ActivityInfo;
-import android.content.pm.PackageManager;
-import android.content.res.XmlResourceParser;
-import android.os.Bundle;
-import android.util.AttributeSet;
-import android.util.Xml;
-import com.android.internal.util.XmlUtils;
-
-import java.io.IOException;
-
-/**
- * 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.
- */
-public class AliasActivity extends Activity {
- /**
- * 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}
- */
- public final String ALIAS_META_DATA = "android.app.alias";
-
- @Override
- protected void onCreate(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 Intent parseAlias(XmlPullParser parser)
- throws XmlPullParserException, IOException {
- 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;
- }
-
-}