1 /* 2 * Copyright (C) 2012 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 android.taskswitching.appa; 18 19 import android.app.ListActivity; 20 import android.os.Bundle; 21 import android.os.Handler; 22 import android.os.RemoteCallback; 23 import android.view.WindowManager; 24 import android.widget.ArrayAdapter; 25 import android.widget.ListView; 26 27 /** 28 * Simple activity to notify completion via broadcast after onResume. 29 * This is for measuring taskswitching time between two apps. 30 */ 31 public class AppAActivity extends ListActivity { 32 private static final int NUMBER_ELEMENTS = 1000; 33 private Handler mHandler; 34 35 private String[] mItems = new String[NUMBER_ELEMENTS]; 36 37 @Override onCreate(Bundle icicle)38 public void onCreate(Bundle icicle) { 39 super.onCreate(icicle); 40 getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED); 41 for (int i = 0; i < NUMBER_ELEMENTS; i++) { 42 mItems[i] = "A" + Integer.toString(i); 43 } 44 setListAdapter(new ArrayAdapter<String>(this, 45 android.R.layout.simple_list_item_1, mItems)); 46 ListView view = getListView(); 47 mHandler = new Handler(); 48 } 49 50 @Override onResume()51 public void onResume() { 52 super.onResume(); 53 mHandler.post(() -> { 54 getIntent().<RemoteCallback>getParcelableExtra("callback").sendResult(null); 55 }); 56 } 57 } 58