blob: 1548d6ed8a03d23a6499c6798d78f4c1938031d6 [file] [log] [blame]
Andrii Kulian962e4342018-01-23 20:17:31 -08001/**
2 * Copyright (c) 2018 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 com.google.android.test.activityview;
18
19import android.app.Activity;
20import android.app.ActivityView;
21import android.content.Intent;
22import android.os.Bundle;
23import android.widget.Button;
24
25public class ActivityViewActivity extends Activity {
26
27 @Override
28 protected void onCreate(Bundle savedInstanceState) {
29 super.onCreate(savedInstanceState);
30 setContentView(R.layout.activity_view_activity);
31
32 final ActivityView activityView = findViewById(R.id.activity_view);
33 final Button launchButton = findViewById(R.id.activity_launch_button);
34 launchButton.setOnClickListener(v -> {
35 final Intent intent = new Intent(this, ActivityViewTestActivity.class);
36 intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
37 activityView.startActivity(intent);
38 });
39 final Button pickActivityLaunchButton = findViewById(R.id.activity_pick_launch_button);
40 pickActivityLaunchButton.setOnClickListener(v -> {
41 final Intent intent = Intent.makeMainActivity(null);
42 final Intent chooser = Intent.createChooser(intent,
43 "Pick an app to launch in ActivityView");
44 if (intent.resolveActivity(getPackageManager()) != null) {
45 chooser.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
46 | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
47 activityView.startActivity(chooser);
48 }
49 });
50 }
51}