• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2014 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 
17 package com.example.android.documentcentricrelinquishidentity;
18 
19 import android.app.Activity;
20 import android.content.Intent;
21 import android.os.Bundle;
22 import android.view.View;
23 
24 /**
25  * Activities that serve as the root of a task may give up certain task identifiers to activities
26  * above it in the task stack. These identifiers include the task base Intent, and the task name,
27  * color and icon used in the recent task list. The base @link{Intent} is used to match the task when
28  * relaunching based on an incoming Intent.
29  *
30  * <p>
31  * To relinquish its identity the base activity must have the activity attribute
32  * android:relinquishTaskIdentity=”true” in the manifest.
33  * </p>
34  */
35 public class RelinquishIdentityActivity extends Activity {
36 
37     @Override
onCreate(Bundle savedInstanceState)38     protected void onCreate(Bundle savedInstanceState) {
39         super.onCreate(savedInstanceState);
40         setContentView(R.layout.activity_relinquish_identity);
41     }
42 
createNewDocument(View view)43     public void createNewDocument(View view) {
44         final Intent intent = newDocumentIntent();
45         startActivity(intent);
46     }
47 
48     /**
49      * Returns an new intent to start {@link NewDocumentActivity}
50      * as a new document in recents..
51      */
newDocumentIntent()52     private Intent newDocumentIntent() {
53         final Intent newDocumentIntent = new Intent(this, NewDocumentActivity.class);
54         newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_DOCUMENT);
55         // Always launch in a new task.
56         newDocumentIntent.addFlags(Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
57         return newDocumentIntent;
58     }
59 
60 }
61