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.content.Intent; 21 22 import android.os.Bundle; 23 import android.os.Handler; 24 import android.view.WindowManager; 25 import android.widget.ArrayAdapter; 26 import android.widget.ListView; 27 28 /** 29 * Simple activity to notify completion via broadcast after onResume. 30 * This is for measuring taskswitching time between two apps. 31 */ 32 public class AppAActivity extends ListActivity { 33 static final String TAG = "AppAActivity"; 34 private static final int NUMBER_ELEMENTS = 1000; 35 private static final String TASKSWITCHING_INTENT = "android.taskswitching.appa"; 36 private Handler mHandler; 37 38 private String[] mItems = new String[NUMBER_ELEMENTS]; 39 40 @Override 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 53 @Override onResume()54 public void onResume() { 55 super.onResume(); 56 mHandler.post(new Runnable() { 57 58 @Override 59 public void run() { 60 Intent intent = new Intent(TASKSWITCHING_INTENT); 61 sendBroadcast(intent); 62 } 63 }); 64 } 65 } 66