/** @see android.os.Handler#handleMessage(android.os.Message) */
        @Override
        public void handleMessage(Message msg) {
          super.handleMessage(msg);
          if (null == msg) return;

          if (null == mActivity || mActivity.isDestroyed() || mActivity.isFinishing()) {
            return;
          }

          mDialog = (Dialog) msg.obj;
          if (null == mDialog) {
            return;
          }

          mDialog.setOwnerActivity(mActivity);
          if (msg.what == SHOW && !mDialog.isShowing()) {
            mDialog.show();
          }
        }
示例#2
0
 /*
  * (non-Javadoc)
  * @see android.app.Activity#onCreateDialog(int)
  */
 @Override
 protected Dialog onCreateDialog(int id) {
   Builder builder;
   switch (id) {
     case DIALOG_FILENAME:
       LayoutInflater factory = LayoutInflater.from(this);
       View view = factory.inflate(R.layout.filenamedialog, null);
       mFileNameView = (EditText) view.findViewById(R.id.fileNameField);
       builder =
           new AlertDialog.Builder(this)
               .setTitle(R.string.dialog_filename_title)
               .setMessage(R.string.dialog_filename_message)
               .setIcon(android.R.drawable.ic_dialog_alert)
               .setView(view)
               .setPositiveButton(R.string.btn_okay, mOnClickListener)
               .setNegativeButton(R.string.btn_cancel, mOnClickListener);
       Dialog dialog = builder.create();
       dialog.setOwnerActivity(this);
       return dialog;
     default:
       return super.onCreateDialog(id);
   }
 }