1

I'm developing an app which fires a dialog from a service. Below is the code that I use to pop a dialog from within the service

   private void popPrescriptionEditDialog() {
    mReadingHandler.post(new Runnable() {
        @Override
        public void run() {
            LayoutInflater inflater = LayoutInflater.from(context);
            final View dialogView = inflater.inflate(R.layout.ble_prescription_edit_dialog, null);


            final Dialog dialog = new Dialog(context, R.style.DialogStyle);
            btnSave = (TextView) dialogView.findViewById(R.id.btnSave);
            btnCancel = (TextView) dialogView.findViewById(R.id.btnCancel);
            final EditText etDosageData = (EditText) dialogView.findViewById(R.id.etDosageData) ;
            dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
            dialog.getWindow().setType(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
            dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
            dialog.setContentView(dialogView);
            dialog.setCancelable(false);
            btnSave.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    displayToast("Data Saved");
                    dialog.dismiss();
                }
            });

            btnCancel.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dialog.dismiss();
                }
            });
            dialog.show();
        }
    });
}

When the EditText etDosageData gets focus, the dialog must shift up and make way for the keypad but the dialog doesn't shift up. Is it because its a System Alert Type dialog? Any suggested workarounds?

Abhinav Tripathi
  • 168
  • 1
  • 2
  • 12

0 Answers0