1 /* 2 * Copyright (C) 2007 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.test; 18 19 import android.app.Activity; 20 import android.os.Bundle; 21 import android.util.Log; 22 23 public class TestActivity extends Activity { 24 private final static String TAG = "TestActivity"; 25 TestView mView; 26 boolean mToggle; 27 int mCount; 28 final static int PAUSE_DELAY = 100; 29 Runnable mRunnable = new Runnable() { 30 public void run() { 31 if (mToggle) { 32 Log.w(TAG, "****** step " + mCount + " resume"); 33 mCount++; 34 mView.onResume(); 35 } else { 36 Log.w(TAG, "step " + mCount + " pause"); 37 mView.onPause(); 38 } 39 mToggle = ! mToggle; 40 mView.postDelayed(mRunnable, PAUSE_DELAY); 41 } 42 }; 43 44 @Override onCreate(Bundle icicle)45 protected void onCreate(Bundle icicle) { 46 super.onCreate(icicle); 47 mView = new TestView(getApplication()); 48 mView.setFocusableInTouchMode(true); 49 setContentView(mView); 50 mView.postDelayed(mRunnable, PAUSE_DELAY); 51 } 52 53 @Override onPause()54 protected void onPause() { 55 super.onPause(); 56 mView.onPause(); 57 } 58 59 @Override onResume()60 protected void onResume() { 61 super.onResume(); 62 mView.onResume(); 63 } 64 } 65