1/*
2 * Copyright (C) 2006 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package android.app.activity;
18
19import android.app.Activity;
20import android.content.Intent;
21import android.os.Bundle;
22import android.util.Log;
23
24public class ClearTop extends Activity {
25    public static final String WAIT_CLEAR_TASK = "waitClearTask";
26
27    public ClearTop() {
28    }
29
30    @Override
31    public void onCreate(Bundle icicle) {
32        super.onCreate(icicle);
33        //Log.i("foo", "Creating: " + this);
34        Intent intent = new Intent(getIntent()).setAction(LocalScreen.CLEAR_TASK)
35                .setClass(this, LocalScreen.class);
36        startActivity(intent);
37    }
38
39    @Override
40    public void onNewIntent(Intent intent) {
41        //Log.i("foo", "New intent in " + this + ": " + intent);
42        if (LocalScreen.CLEAR_TASK.equals(intent.getAction())) {
43            setResult(RESULT_OK);
44        } else {
45            setResult(RESULT_CANCELED, new Intent().setAction(
46                    "New intent received " + intent + ", expecting action "
47                    + TestedScreen.CLEAR_TASK));
48        }
49        finish();
50    }
51}
52