1 /* 2 * Copyright (C) 2021 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.android.cts.verifier.notifications; 18 19 import android.app.Activity; 20 import android.content.Context; 21 import android.content.Intent; 22 import android.os.Bundle; 23 import android.view.WindowManager; 24 import android.widget.TextView; 25 26 import androidx.annotation.Nullable; 27 28 import com.android.cts.verifier.R; 29 30 /** 31 * A simple activity which will show over the lockscreen (like an ongoing phone call). 32 */ 33 public class ShowWhenLockedActivity extends Activity { 34 private static final String KEY_DESCRIPTION = "desc"; 35 36 /** 37 * Create the intent which can start this activity 38 * @param description The text to be shown on the activity 39 */ makeActivityIntent(Context context, String description)40 public static Intent makeActivityIntent(Context context, String description) { 41 return new Intent(context, ShowWhenLockedActivity.class) 42 .putExtra(KEY_DESCRIPTION, description) 43 .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); 44 } 45 46 @Override onCreate(@ullable Bundle savedInstanceState)47 protected void onCreate(@Nullable Bundle savedInstanceState) { 48 getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); 49 super.onCreate(savedInstanceState); 50 setContentView(R.layout.activity_show_when_locked); 51 String description = getIntent().getStringExtra(KEY_DESCRIPTION); 52 this.<TextView>findViewById(R.id.description).setText(description); 53 } 54 } 55