summaryrefslogtreecommitdiff
path: root/apps/Development/src/com/android/development/ShowActivity.java
blob: 1fc2816402f1c098850110f268841f4bcbd90926 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
/* //device/apps/Settings/src/com/android/settings/Keyguard.java
**
** Copyright 2006, 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 com.android.development;

import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.provider.Settings;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;


public class ShowActivity extends Activity {

    private ActivityInfo mActivityInfo;

    private TextView mPackage;
    private ImageView mIconImage;
    private TextView mClass;
    private TextView mLabel;
    private TextView mLaunch;
    private TextView mProcess;
    private TextView mTaskAffinity;
    private TextView mPermission;
    private TextView mMultiprocess;
    private TextView mClearOnBackground;
    private TextView mStateNotNeeded;

    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);

        setContentView(R.layout.show_activity);

        mPackage = (TextView)findViewById(R.id.packageView);
        mIconImage = (ImageView)findViewById(R.id.icon);
        mClass = (TextView)findViewById(R.id.classView);
        mLabel = (TextView)findViewById(R.id.label);
        mLaunch = (TextView)findViewById(R.id.launch);
        mProcess = (TextView)findViewById(R.id.process);
        mTaskAffinity = (TextView)findViewById(R.id.taskAffinity);
        mPermission = (TextView)findViewById(R.id.permission);
        mMultiprocess = (TextView)findViewById(R.id.multiprocess);
        mClearOnBackground = (TextView)findViewById(R.id.clearOnBackground);
        mStateNotNeeded = (TextView)findViewById(R.id.stateNotNeeded);

        final PackageManager pm = getPackageManager();
        try {
            mActivityInfo = pm.getActivityInfo(ComponentName.unflattenFromString(
                getIntent().getData().getSchemeSpecificPart()), 0);
        } catch (PackageManager.NameNotFoundException e) {
        }
        if (mActivityInfo != null) {
            mPackage.setText(mActivityInfo.applicationInfo.packageName);
            mIconImage.setImageDrawable(mActivityInfo.loadIcon(pm));
            if (mActivityInfo.name.startsWith(
                    mActivityInfo.applicationInfo.packageName + ".")) {
                mClass.setText(mActivityInfo.name.substring(
                        mActivityInfo.applicationInfo.packageName.length()));
            } else {
                mClass.setText(mActivityInfo.name);
            }
            CharSequence label = mActivityInfo.loadLabel(pm);
            mLabel.setText("\"" + (label != null ? label : "") + "\"");
            switch (mActivityInfo.launchMode) {
            case ActivityInfo.LAUNCH_MULTIPLE:
                mLaunch.setText(getText(R.string.launch_multiple));
                break;
            case ActivityInfo.LAUNCH_SINGLE_TOP:
                mLaunch.setText(getText(R.string.launch_singleTop));
                break;
            case ActivityInfo.LAUNCH_SINGLE_TASK:
                mLaunch.setText(getText(R.string.launch_singleTask));
                break;
            case ActivityInfo.LAUNCH_SINGLE_INSTANCE:
                mLaunch.setText(getText(R.string.launch_singleInstance));
                break;
            default:
                mLaunch.setText(getText(R.string.launch_unknown));
            }
            mProcess.setText(mActivityInfo.processName);
            mTaskAffinity.setText(mActivityInfo.taskAffinity != null
                    ? mActivityInfo.taskAffinity : getText(R.string.none));
            mPermission.setText(mActivityInfo.permission != null
                    ? mActivityInfo.permission : getText(R.string.none));
            mMultiprocess.setText(
                    (mActivityInfo.flags&ActivityInfo.FLAG_MULTIPROCESS) != 0
                    ? getText(R.string.yes) : getText(R.string.no));
            mClearOnBackground.setText(
                    (mActivityInfo.flags&ActivityInfo.FLAG_CLEAR_TASK_ON_LAUNCH) != 0
                    ? getText(R.string.yes) : getText(R.string.no));
            mStateNotNeeded.setText(
                    (mActivityInfo.flags&ActivityInfo.FLAG_STATE_NOT_NEEDED) != 0
                    ? getText(R.string.yes) : getText(R.string.no));
        }
    }

    public void onResume() {
        super.onResume();
    }
}