am 39c59f7e: Initialize voiceDialer in onCreate instead of onStart
* commit '39c59f7ec34aca397d5e9dad23d72e54bda9f469':
Initialize voiceDialer in onCreate instead of onStart
diff --git a/src/com/android/voicedialer/VoiceDialerActivity.java b/src/com/android/voicedialer/VoiceDialerActivity.java
index c6ac216..ea80e2c 100644
--- a/src/com/android/voicedialer/VoiceDialerActivity.java
+++ b/src/com/android/voicedialer/VoiceDialerActivity.java
@@ -183,17 +183,18 @@
@Override
protected void onCreate(Bundle icicle) {
- if (false) Log.d(TAG, "onCreate");
super.onCreate(icicle);
+ // TODO: All of this state management and holding of
+ // connections to the TTS engine and recognizer really
+ // belongs in a service. The activity can be stopped or deleted
+ // and recreated for lots of reasons.
+ // It's way too late in the ICS release cycle for a change
+ // like this now though.
+ // MHibdon Sept 20 2011
mHandler = new Handler();
mAudioManager = (AudioManager)getSystemService(AUDIO_SERVICE);
mToneGenerator = new ToneGenerator(AudioManager.STREAM_RING,
ToneGenerator.MAX_VOLUME);
- }
-
- protected void onStart() {
- if (false) Log.d(TAG, "onStart " + getIntent());
- super.onStart();
acquireWakeLock(this);
@@ -1098,9 +1099,7 @@
return msecDelay;
}
- protected void onStop() {
- if (false) Log.d(TAG, "onStop");
-
+ protected void onDestroy() {
synchronized(this) {
mState = EXITING;
}
@@ -1143,19 +1142,16 @@
}
unregisterReceiver(mReceiver);
- super.onStop();
+ super.onDestroy();
releaseWakeLock();
-
- // It makes no sense to have this activity maintain state when in
- // background. When it stops, it should just be destroyed.
- finish();
}
private void acquireWakeLock(Context context) {
if (mWakeLock == null) {
PowerManager pm = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
- mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "VoiceDialer");
+ mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,
+ "VoiceDialer");
mWakeLock.acquire();
}
}
@@ -1177,10 +1173,4 @@
mHandler.postDelayed(this, 750);
}
};
-
- @Override
- protected void onDestroy() {
- if (false) Log.d(TAG, "onDestroy");
- super.onDestroy();
- }
}