FileDocCategorySizeDatePackage
ToneDialog.javaAPI DocAndroid 1.5 API3971Wed May 06 22:42:48 BST 2009com.android.stk

ToneDialog

public class ToneDialog extends android.app.Activity
Activity used for PLAY TONE command.

Fields Summary
com.android.internal.telephony.gsm.stk.TextMessage
toneMsg
com.android.internal.telephony.gsm.stk.ToneSettings
settings
TonePlayer
player
android.os.Handler
mToneStopper
Handler used to stop tones from playing when the duration ends.
android.os.Vibrator
mVibrator
private static final int
MSG_ID_STOP_TONE
Constructors Summary
Methods Summary
private voidinitFromIntent(android.content.Intent intent)

        if (intent == null) {
            finish();
        }
        toneMsg = intent.getParcelableExtra("TEXT");
        settings = intent.getParcelableExtra("TONE");
    
protected voidonCreate(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 voidonDestroy()

        super.onDestroy();

        mToneStopper.removeMessages(MSG_ID_STOP_TONE);
        player.stop();
        player.release();
        mVibrator.cancel();
    
public booleanonKeyDown(int keyCode, android.view.KeyEvent event)

        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            sendResponse(StkAppService.RES_ID_END_SESSION);
            finish();
            break;
        }
        return false;
    
private voidsendResponse(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));