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