Methods Summary |
---|
private void | initFromIntent(android.content.Intent intent)
if (intent == null) {
finish();
}
toneMsg = intent.getParcelableExtra("TEXT");
settings = intent.getParcelableExtra("TONE");
|
protected void | onCreate(android.os.Bundle icicle)
super.onCreate(icicle);
initFromIntent(getIntent());
// remove window title
View title = findViewById(com.android.internal.R.id.title);
title.setVisibility(View.GONE);
// set customized content view
setContentView(R.layout.stk_tone_dialog);
TextView tv = (TextView) findViewById(R.id.message);
ImageView iv = (ImageView) findViewById(R.id.icon);
// set text and icon
tv.setText(toneMsg.text);
if (toneMsg.icon == null) {
iv.setImageResource(com.android.internal.R.drawable.ic_volume);
} else {
iv.setImageBitmap(toneMsg.icon);
}
// Start playing tone and vibration
player = new TonePlayer();
player.play(settings.tone);
int timeout = StkApp.calculateDurationInMilis(settings.duration);
if (timeout == 0) {
timeout = StkApp.TONE_DFEAULT_TIMEOUT;
}
mToneStopper.sendEmptyMessageDelayed(MSG_ID_STOP_TONE, timeout);
if (settings.vibrate) {
mVibrator.vibrate(timeout);
}
|
protected void | onDestroy()
super.onDestroy();
mToneStopper.removeMessages(MSG_ID_STOP_TONE);
player.stop();
player.release();
mVibrator.cancel();
|
public boolean | onKeyDown(int keyCode, android.view.KeyEvent event)
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
sendResponse(StkAppService.RES_ID_END_SESSION);
finish();
break;
}
return false;
|
private void | sendResponse(int resId)
Bundle args = new Bundle();
args.putInt(StkAppService.OPCODE, StkAppService.OP_RESPONSE);
args.putInt(StkAppService.RES_ID, resId);
startService(new Intent(this, StkAppService.class).putExtras(args));
|