Example usage for android.view.inputmethod InputMethodManager RESULT_SHOWN

List of usage examples for android.view.inputmethod InputMethodManager RESULT_SHOWN

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager RESULT_SHOWN.

Prototype

int RESULT_SHOWN

To view the source code for android.view.inputmethod InputMethodManager RESULT_SHOWN.

Click Source Link

Document

Flag for the ResultReceiver result code from #showSoftInput(View,int,ResultReceiver) and #hideSoftInputFromWindow(IBinder,int,ResultReceiver) : the state of the soft input window changed from hidden to shown.

Usage

From source file:Main.java

public static void showSoftKeyBoard(Context context, EditText edit) {
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(edit, InputMethodManager.RESULT_SHOWN);
    imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
}

From source file:edu.missouri.bas.activities.AdminManageActivity.java

private Dialog AdminPinDialog(Context context) {
    LayoutInflater inflater = LayoutInflater.from(this);
    final View textEntryView = inflater.inflate(R.layout.pin_login, null);
    alert_text = (TextView) textEntryView.findViewById(R.id.pin_text);
    alert_text.setText("Please input PIN for administrator");
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*ww  w . j  a v  a 2s  .co  m*/
    builder.setTitle("Verify Admin PIN");
    builder.setView(textEntryView);
    //builder.setMessage("Please input PIN for administrator");
    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            //check networking

            adminPin = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String AdPin = adminPin.getText().toString();
            Log.d(TAG, "get from edittext is " + AdPin);

            HttpPost request = new HttpPost(
                    "http://dslsrv8.cs.missouri.edu/~rs79c/Server/Crt/validateUser.php");

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            //file_name 
            params.add(new BasicNameValuePair("userID", "0000"));
            //function
            params.add(new BasicNameValuePair("pre", "1"));
            //data                       
            params.add(new BasicNameValuePair("password", AdPin));

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                        //setResult(8);
                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast toast = Toast.makeText(getApplicationContext(),
                                "Admin PIN is wrong, exit! Please try again.", Toast.LENGTH_SHORT);
                        toast.show();
                        //set return code
                        /*                            if(shp.getString(ASID, "").equals("")){
                                                       setResult(9);
                                                    }else{
                                                       setResult(Activity.RESULT_CANCELED);
                                                    }*/
                        //setResult(9);
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast toast = Toast.makeText(getApplicationContext(),
                                "Verify failed. Please try again.", Toast.LENGTH_SHORT);
                        toast.show();
                        //set return code
                        /*                            if(shp.getString(ASID, "").equals("")){
                                                       setResult(9);
                                                    }else{
                                                       setResult(Activity.RESULT_CANCELED);
                                                    }*/
                        finish();
                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast toast = Toast.makeText(getApplicationContext(),
                        "Failed. Please try again, with network connection.", Toast.LENGTH_SHORT);
                toast.show();
                //set return code
                /*                        if(shp.getString(ASID, "").equals("")){
                   setResult(9);
                }else{
                   setResult(Activity.RESULT_CANCELED);
                }*/

                finish();
                e.printStackTrace();
            }

        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            //set return code
            /*                    if(shp.getString(ASID, "").equals("")){
               setResult(9);
            }else{
               setResult(Activity.RESULT_CANCELED);
            }*/
            setResult(9);
            finish();
        }
    });
    return builder.create();
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private Dialog AdminPinSetDialog(Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.pin_input, null);
    TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text);
    pinText.setText(R.string.admin_set_msg);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);/*from ww w. j  av a2  s.  c o m*/
    builder.setTitle(R.string.admin_set_title);
    builder.setView(textEntryView);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String pinStr = pinEdite.getText().toString();
            Utilities.Log("Pin Dialog", "pin String is " + pinStr);

            String data = null;
            try {
                data = Utilities.encryption("0000" + "," + "1" + "," + pinStr);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            /*            check network*/

            /*            prepare params for server*/
            HttpPost request = new HttpPost(Utilities.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //               //file_name
            //               params.add(new BasicNameValuePair("userID","0000"));
            //               //function
            //               params.add(new BasicNameValuePair("pre","1"));
            //               //data
            //               params.add(new BasicNameValuePair("password",pinStr));

            /*            check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT)
                            .show();
                    finish();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT)
                        .show();
                ;
                finish();
            }

        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            finish();
        }
    });

    return builder.create();
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private Dialog AdminPinSetDialog(final Context context) {
    LayoutInflater inflater = LayoutInflater.from(context);
    final View textEntryView = inflater.inflate(R.layout.pin_input, null);
    TextView pinText = (TextView) textEntryView.findViewById(R.id.pin_text);
    pinText.setText(R.string.admin_set_msg);
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setCancelable(false);//from   ww w .  java2  s . c o m
    builder.setTitle(R.string.admin_set_title);
    builder.setView(textEntryView);
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            EditText pinEdite = (EditText) textEntryView.findViewById(R.id.pin_edit);
            String pinStr = pinEdite.getText().toString();
            Util.Log_debug("Pin Dialog", "pin String is " + pinStr);

            String data = null;
            try {
                data = Util.encryption(context, Util.ADMIN_UID + "," + "1" + "," + pinStr);
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            /*              check network*/

            /*              prepare params for server*/
            HttpPost request = new HttpPost(Util.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //              //file_name
            //              params.add(new BasicNameValuePair("userID","0000"));
            //              //function
            //              params.add(new BasicNameValuePair("pre","1"));
            //              //data
            //              params.add(new BasicNameValuePair("password",pinStr));

            /*              check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result", result);

                    if (result.equals("AdminIsChecked")) {
                        //do nothing

                    } else if (result.equals("AdminPinIsInvalid")) {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_failed, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    } else {

                        imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                        Toast.makeText(getApplicationContext(), R.string.input_apin_error, Toast.LENGTH_SHORT)
                                .show();
                        finish();
                    }
                } else {
                    Toast.makeText(getApplicationContext(), R.string.input_apin_return, Toast.LENGTH_SHORT)
                            .show();
                    finish();
                }

            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Toast.makeText(getApplicationContext(), R.string.input_apin_net_error, Toast.LENGTH_SHORT)
                        .show();
                ;
                finish();
            }

        }
    });

    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {

            imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
            imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

            finish();
        }
    });

    return builder.create();
}

From source file:org.videolan.vlc.gui.SearchFragment.java

public void onSearchKeyPressed() {
    if (mSearchText == null)
        return;// w  ww  .  j a va2  s .c  o  m
    mSearchText.requestFocus();
    mSearchText.setSelection(mSearchText.getText().length());
    InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(mSearchText, InputMethodManager.RESULT_SHOWN);
}

From source file:edu.missouri.niaaa.pain.activity.AdminManageActivity.java

private void setListeners() {
    // TODO Auto-generated method stub
    Log.d(TAG, "Ontabchangedlistener!!~~~");
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override// w  ww.ja  va2  s. co  m
        public void onTabChanged(String arg0) {
            // TODO Auto-generated method stub
            Log.d(TAG, "~~" + arg0);

            setHints();

            if (arg0.equals("Assign ID")) {
                imm.toggleSoftInput(0, InputMethodManager.RESULT_HIDDEN);

                Log.d(TAG, "assign id ");

            } else {

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Log.d(TAG, "deassign id");

            }
        }

    });

    AssignButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "assign btn " + asID.getText().toString());

            //editor.putString(ASID, asID.getText().toString());
            //format check

            //editor.putString(ASPWD, "");
            //editor.commit();
            //setHints();

            /*              check network*/

            /*              prepare params for server*/
            String asedID = asID.getText().toString();
            Log.d(TAG, "get from edittext is " + asedID);

            String data = null;
            try {
                data = Util.encryption(AdminManageActivity.this, asedID + "," + "2");
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            HttpPost request = new HttpPost(Util.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //              //file_name
            //              params.add(new BasicNameValuePair("userID",asedID));
            //              //function
            //              params.add(new BasicNameValuePair("pre","2"));
            //              //data
            //              //params.add(new BasicNameValuePair("password",""));

            /*              check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result2 ", result);

                    if (result.equals("UserIDIsNotSet")) {
                        //add in web page first

                        String s1 = getString(R.string.assign_id_null);
                        assignFailDialog(ctx, s1).show();

                    } else if (result.equals("UserIDIsUsed")) {
                        String s2 = getString(R.string.assing_id_exist) + asedID;
                        assignConfirmDialog(ctx, s2, true).show();

                    } else if (result.equals("UserIDIsNotActive")) {
                        //assign
                        String s3 = getString(R.string.assign_id_new) + asedID;
                        assignConfirmDialog(ctx, s3, false).show();

                    } else {
                        String s4 = getString(R.string.assign_id_wrong);
                        assignFailDialog(ctx, s4).show();

                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                String s4 = getString(R.string.assign_id_net_error);
                assignFailDialog(ctx, s4).show();
            }
        }
    });

    RemoveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "remove btn ");

            //add a confirm dialog

            setHints();
            Log.d(TAG, "cur is " + currentAssID);

            if (!currentAssID.equals("")) {
                removeDialog(ctx).show();
            }
        }
    });
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

private void setListeners() {
    // TODO Auto-generated method stub
    Log.d(TAG, "Ontabchangedlistener!!~~~");
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override//from www .  ja  v  a2  s  .  c om
        public void onTabChanged(String arg0) {
            // TODO Auto-generated method stub
            Log.d(TAG, "~~" + arg0);

            setHints();

            if (arg0.equals("Assign ID")) {
                imm.toggleSoftInput(0, InputMethodManager.RESULT_HIDDEN);

                Log.d(TAG, "assign id ");

            } else {

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Log.d(TAG, "deassign id");

            }
        }

    });

    AssignButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "assign btn " + asID.getText().toString());

            //editor.putString(ASID, asID.getText().toString());
            //format check

            //editor.putString(ASPWD, "");
            //editor.commit();
            //setHints();

            /*            check network*/

            /*            prepare params for server*/
            String asedID = asID.getText().toString();
            Log.d(TAG, "get from edittext is " + asedID);

            String data = null;
            try {
                data = Utilities.encryption(asedID + "," + "2");
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }

            HttpPost request = new HttpPost(Utilities.VALIDATE_ADDRESS);

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            params.add(new BasicNameValuePair("data", data));

            //               //file_name
            //               params.add(new BasicNameValuePair("userID",asedID));
            //               //function
            //               params.add(new BasicNameValuePair("pre","2"));
            //               //data
            //               //params.add(new BasicNameValuePair("password",""));

            /*            check identity*/

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result2 ", result);

                    if (result.equals("UserIDIsNotSet")) {
                        //add in web page first

                        String s1 = getString(R.string.assign_id_null);
                        assignFailDialog(ctx, s1).show();

                    } else if (result.equals("UserIDIsUsed")) {
                        String s2 = getString(R.string.assing_id_exist) + asedID;
                        assignConfirmDialog(ctx, s2, true).show();

                    } else if (result.equals("UserIDIsNotActive")) {
                        //assign
                        String s3 = getString(R.string.assign_id_new) + asedID;
                        assignConfirmDialog(ctx, s3, false).show();

                    } else {
                        String s4 = getString(R.string.assign_id_wrong);
                        assignFailDialog(ctx, s4).show();

                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                String s4 = getString(R.string.assign_id_net_error);
                assignFailDialog(ctx, s4).show();
            }
        }
    });

    RemoveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "remove btn ");

            //add a confirm dialog

            setHints();
            Log.d(TAG, "cur is " + currentAssID);

            if (!currentAssID.equals("")) {
                removeDialog(ctx).show();
            }
        }
    });
}

From source file:edu.missouri.bas.activities.AdminManageActivity.java

private void setListeners() {
    // TODO Auto-generated method stub
    Log.d(TAG, "Ontabchangedlistener!!~~~");
    tabHost.setOnTabChangedListener(new OnTabChangeListener() {

        @Override/*w  w  w  . j ava 2  s . com*/
        public void onTabChanged(String arg0) {
            // TODO Auto-generated method stub
            Log.d(TAG, "~~" + arg0);

            setHints();

            if (arg0.equals("Assign ID")) {
                imm.toggleSoftInput(0, InputMethodManager.RESULT_HIDDEN);

                Log.d(TAG, "assign id ");

            } else {

                imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
                imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);

                Log.d(TAG, "deassign id");

            }
        }

    });

    AssignButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "assign btn " + asID.getText().toString());

            //editor.putString(ASID, asID.getText().toString());
            //format check

            //editor.putString(ASPWD, "");
            //editor.commit();
            //setHints();

            //check networking

            String asedID = asID.getText().toString();
            Log.d(TAG, "get from edittext is " + asedID);

            HttpPost request = new HttpPost(
                    "http://dslsrv8.cs.missouri.edu/~rs79c/Server/Crt/validateUser.php");

            List<NameValuePair> params = new ArrayList<NameValuePair>();

            //file_name 
            params.add(new BasicNameValuePair("userID", asedID));
            //function
            params.add(new BasicNameValuePair("pre", "2"));
            //data                       
            //params.add(new BasicNameValuePair("password",""));

            try {
                request.setEntity(new UrlEncodedFormEntity(params, HTTP.UTF_8));

                HttpResponse response = new DefaultHttpClient().execute(request);
                if (response.getStatusLine().getStatusCode() == 200) {
                    String result = EntityUtils.toString(response.getEntity());
                    Log.d("~~~~~~~~~~http post result2 ", result);

                    if (result.equals("UserIDIsNotSet")) {
                        //add in web page first

                        String s1 = "This ID is not in Database, please double check or add it via web page by administrator first.";
                        buildDialog1(ctx, s1).show();
                        setResult(9);

                    } else if (result.equals("UserIDIsUsed")) {
                        String s2 = "This ID has been used before. Delete it via web page by administrator first.";
                        buildDialog2(ctx, s2).show();
                        setResult(9);

                    } else if (result.equals("UserIDIsNotActive")) {
                        //assign
                        String s3 = "Do you want to assign this ID: " + asedID;
                        buildDialog2(ctx, s3).show();

                    } else {
                        String s4 = "The ID format seems not applicable, please try again.";
                        buildDialog1(ctx, s4).show();
                        setResult(9);

                    }

                }
            } catch (Exception e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
                String s4 = "The ID format seems not applicable, please try again.";
                buildDialog1(ctx, s4).show();
                setResult(9);
            }

        }
    });

    RemoveButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Log.d(TAG, "remove btn ");

            //add a confirm dialog

            setHints();
            Log.d(TAG, "cur is " + currentAssID);

            if (!currentAssID.equals("")) {
                Dialog alertDialog = new AlertDialog.Builder(ctx).setCancelable(false)
                        .setTitle("Confirm Remove")
                        .setMessage(
                                "Do you really want to remove this ID and all related data from the device? ")
                        .setPositiveButton("OK", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                // TODO Auto-generated method stub  
                                editor.putString(ASID, "");
                                editor.putString(ASPWD, "");
                                editor.commit();
                                editor2.putString(SensorService.BED_TIME_INFO, "none");
                                editor2.putString(SensorService.BED_HOUR_INFO, "none");
                                editor2.putString(SensorService.BED_MIN_INFO, "none");
                                editor2.putInt("RandomSurveyStartHour", 11);
                                editor2.putInt("RandomSurveyStartMin", 59);
                                //editor2.putBoolean("MornReportDone", false);
                                editor2.commit();

                                setHints();
                                SensorService.mIsRunning = false;
                                ctx.stopService(new Intent(AdminManageActivity.this, SensorService.class));
                                setResult(9);
                                finish();
                            }
                        }).setNegativeButton("Cancel", new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                // TODO Auto-generated method stub  

                            }
                        }).create();

                alertDialog.show();
            }
        }
    });
}

From source file:edu.missouri.niaaa.ema.activity.AdminManageActivity.java

@Override
protected void onDestroy() {
    super.onDestroy();
    DialadminPin.dismiss();/*w  w  w.ja  v  a  2 s .  c o m*/

    imm.toggleSoftInput(0, InputMethodManager.RESULT_SHOWN);
    imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
}