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

StkDialogActivity

public class StkDialogActivity extends android.app.Activity implements View.OnClickListener
AlretDialog used for DISPLAY TEXT commands.

Fields Summary
com.android.internal.telephony.gsm.stk.TextMessage
mTextMsg
android.os.Handler
mTimeoutHandler
private static final String
TEXT
private static final int
MSG_ID_TIMEOUT
public static final int
OK_BUTTON
public static final int
CANCEL_BUTTON
Constructors Summary
Methods Summary
private voidcancelTimeOut()

        mTimeoutHandler.removeMessages(MSG_ID_TIMEOUT);
    
private voidinitFromIntent(android.content.Intent intent)


        if (intent != null) {
            mTextMsg = intent.getParcelableExtra("TEXT");
        } else {
            finish();
        }
    
public voidonClick(android.view.View v)

        String input = null;

        switch (v.getId()) {
        case OK_BUTTON:
            sendResponse(StkAppService.RES_ID_CONFIRM, true);
            finish();
            break;
        case CANCEL_BUTTON:
            sendResponse(StkAppService.RES_ID_CONFIRM, false);
            finish();
            break;
        }
    
protected voidonCreate(android.os.Bundle icicle)


    
        
        super.onCreate(icicle);

        initFromIntent(getIntent());
        if (mTextMsg == null) {
            finish();
            return;
        }

        requestWindowFeature(Window.FEATURE_LEFT_ICON);
        Window window = getWindow();

        setContentView(R.layout.stk_msg_dialog);
        TextView mMessageView = (TextView) window
                .findViewById(R.id.dialog_message);

        Button okButton = (Button) findViewById(R.id.button_ok);
        Button cancelButton = (Button) findViewById(R.id.button_cancel);

        okButton.setOnClickListener(this);
        cancelButton.setOnClickListener(this);

        setTitle(mTextMsg.title);
        if (!(mTextMsg.iconSelfExplanatory && mTextMsg.icon != null)) {
            mMessageView.setText(mTextMsg.text); 
        }

        if (mTextMsg.icon == null) {
            window.setFeatureDrawableResource(Window.FEATURE_LEFT_ICON,
                    com.android.internal.R.drawable.stat_notify_sim_toolkit);
        } else {
            window.setFeatureDrawable(Window.FEATURE_LEFT_ICON,
                    new BitmapDrawable(mTextMsg.icon));
        }
    
public booleanonKeyDown(int keyCode, android.view.KeyEvent event)

        switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            sendResponse(StkAppService.RES_ID_BACKWARD);
            finish();
            break;
        }
        return false;
    
public voidonPause()

        super.onPause();

        cancelTimeOut();
    
public voidonRestoreInstanceState(android.os.Bundle savedInstanceState)

        super.onRestoreInstanceState(savedInstanceState);
        
        mTextMsg = savedInstanceState.getParcelable(TEXT);
    
public voidonResume()

        super.onResume();

        startTimeOut();
    
public voidonSaveInstanceState(android.os.Bundle outState)

        super.onSaveInstanceState(outState);

        outState.putParcelable(TEXT, mTextMsg);
    
private voidsendResponse(int resId, boolean confirmed)

        Bundle args = new Bundle();
        args.putInt(StkAppService.OPCODE, StkAppService.OP_RESPONSE);
        args.putInt(StkAppService.RES_ID, resId);
        args.putBoolean(StkAppService.CONFIRMATION, confirmed);
        startService(new Intent(this, StkAppService.class).putExtras(args));
    
private voidsendResponse(int resId)

        sendResponse(resId, true);
    
private voidstartTimeOut()

        // Reset timeout.
        cancelTimeOut();
        int dialogDuration = StkApp.calculateDurationInMilis(mTextMsg.duration);
        if (dialogDuration == 0) {
            dialogDuration = StkApp.UI_TIMEOUT;
        }
        mTimeoutHandler.sendMessageDelayed(mTimeoutHandler
                .obtainMessage(MSG_ID_TIMEOUT), dialogDuration);