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