Example usage for android.content DialogInterface cancel

List of usage examples for android.content DialogInterface cancel

Introduction

In this page you can find the example usage for android.content DialogInterface cancel.

Prototype

void cancel();

Source Link

Document

Cancels the dialog, invoking the OnCancelListener .

Usage

From source file:com.androidaq.AndroiDAQTCPMain.java

@Override
public Dialog onCreateDialog(int id) {
    switch (id) {
    case CLEAR_SCREEN:
        return new AlertDialog.Builder(AndroiDAQTCPMain.this).setIcon(android.R.drawable.ic_dialog_alert)
                .setMessage("Do you really want to clear the screen and its data?")
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override//ww  w.j a v  a2s .  co  m
                    public void onClick(DialogInterface dialog, int whichButton) {
                        clearScreen();
                    }
                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.cancel();
                    }
                }).create();
    case DELETE:
        return new AlertDialog.Builder(AndroiDAQTCPMain.this).setIcon(android.R.drawable.ic_dialog_alert)
                .setMessage("Do you really want to delete the log file and its data?")
                .setPositiveButton("Yes", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        fromADCSample = false;
                        fromMenu = true;
                        String message8 = "08\r";
                        sendMessage(message8);
                    }
                }).setNegativeButton("No", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.cancel();
                    }
                }).create();
    case TOO_MANY_PULSED:
        return new AlertDialog.Builder(AndroiDAQTCPMain.this).setIcon(android.R.drawable.ic_dialog_alert)
                .setMessage("You can only set 8 channels for frequency output! Please check your settings.")
                .setNegativeButton("OK", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        dialog.cancel();
                    }
                }).create();
    }
    return null;
}

From source file:com.moonpi.tapunlock.MainActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    // Scan NFC Tag dialog, inflate image
    LayoutInflater factory = LayoutInflater.from(MainActivity.this);
    final View view = factory.inflate(R.layout.scan_tag_image, null);

    // Ask for tagTitle (tagName) in dialog
    final EditText tagTitle = new EditText(this);
    tagTitle.setHint(getResources().getString(R.string.set_tag_name_dialog_hint));
    tagTitle.setSingleLine(true);//  ww w. jav  a2 s .c o  m
    tagTitle.setInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);

    // Set tagTitle maxLength
    int maxLength = 50;
    InputFilter[] array = new InputFilter[1];
    array[0] = new InputFilter.LengthFilter(maxLength);
    tagTitle.setFilters(array);

    final LinearLayout l = new LinearLayout(this);

    l.setOrientation(LinearLayout.VERTICAL);
    l.addView(tagTitle);

    // Dialog that shows scan tag image
    if (id == DIALOG_READ) {
        return new AlertDialog.Builder(this).setTitle(R.string.scan_tag_dialog_title).setView(view)
                .setCancelable(false)
                .setNeutralButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialogCancelled = true;
                        killForegroundDispatch();
                        dialog.cancel();
                    }
                }).create();
    }

    // Dialog that asks for tagName and stores it after 'Ok' pressed
    else if (id == DIALOG_SET_TAGNAME) {
        tagTitle.requestFocus();
        return new AlertDialog.Builder(this).setTitle(R.string.set_tag_name_dialog_title).setView(l)
                .setCancelable(false)
                .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        JSONObject newTag = new JSONObject();

                        try {
                            newTag.put("tagName", tagTitle.getText());
                            newTag.put("tagID", tagID);

                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        tags.put(newTag);

                        writeToJSON();

                        adapter.notifyDataSetChanged();

                        updateListViewHeight(listView);

                        if (tags.length() == 0)
                            noTags.setVisibility(View.VISIBLE);

                        else
                            noTags.setVisibility(View.INVISIBLE);

                        Toast toast = Toast.makeText(getApplicationContext(), R.string.toast_tag_added,
                                Toast.LENGTH_SHORT);
                        toast.show();

                        imm.hideSoftInputFromWindow(tagTitle.getWindowToken(), 0);

                        tagID = "";
                        tagTitle.setText("");
                    }
                }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        tagID = "";
                        tagTitle.setText("");
                        imm.hideSoftInputFromWindow(tagTitle.getWindowToken(), 0);
                        dialog.cancel();
                    }
                }).create();
    }

    return null;
}

From source file:com.taw.gotothere.GoToThereActivity.java

/**
 * Displays the first-run dialog.//w  ww  . ja va2  s . c o m
 */
private void displayFirstRunDialog() {

    final SharedPreferences prefs = getPreferences(MODE_PRIVATE);

    new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.first_run_dialog_title))
            .setMessage(getResources().getString(R.string.first_run_text))
            .setPositiveButton(getResources().getString(R.string.accept_button_label),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            prefs.edit().putBoolean(ACCEPTED_TOC, true).commit();
                        }
                    })
            .setNegativeButton(getResources().getString(R.string.dont_accept_button_label),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                            finish();
                        }
                    })
            .show();
}

From source file:com.taw.gotothere.GoToThereActivity.java

/**
 * Display a dialog asking the user if they want to access the location
 * settings/*from   w ww.j av  a 2  s . c o m*/
 */
private void displayLocationSettingsDialog() {
    new AlertDialog.Builder(this).setTitle(getResources().getString(R.string.gps_dialog_title))
            .setMessage(getResources().getString(R.string.gps_dialog_text))
            .setPositiveButton(getResources().getString(R.string.yes_button_label),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
                        }
                    })
            .setNegativeButton(getResources().getString(R.string.no_button_label),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            dialog.cancel();
                        }
                    })
            .show();
}

From source file:org.thomasamsler.android.flashcards.fragment.CardSetsFragment.java

private void deleteCardSet(final int listItemPosition) {

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setMessage(R.string.delete_card_set_dialog_message);
    builder.setCancelable(false);//from w  w w .j  a  v  a  2  s . c om
    builder.setPositiveButton(R.string.delete_card_set_dialog_ok, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            CardSet cardSet = mCardSets.get(listItemPosition);
            List<CardSet> cardSets = mDataSource.getCardSets();

            if (cardSets.contains(cardSet)) {

                mDataSource.deleteCardSet(cardSet);
            }

            mCardSets.remove(listItemPosition);
            Collections.sort(mCardSets);
            mArrayAdapter.notifyDataSetChanged();
        }
    });

    builder.setNegativeButton(R.string.delete_card_set_dialog_cancel, new DialogInterface.OnClickListener() {

        public void onClick(DialogInterface dialog, int which) {

            dialog.cancel();
        }
    });

    AlertDialog alert = builder.create();
    alert.show();
}

From source file:com.example.emachine.FXcalcActivity.java

private void textDialog(String title, String dialogtext) {
    // get prompts.xml view
    String returnString = "";
    hideKeyboard();// w  w w  .j a va  2s.co  m
    LayoutInflater li = LayoutInflater.from(getBaseContext());
    View promptsView = li.inflate(R.layout.alertdialog_sysmsg_dialog, null);

    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);

    // set prompts.xml to alertdialog builder
    alertDialogBuilder.setView(promptsView);

    final EditText userInput = (EditText) promptsView.findViewById(R.id.editTextDialogUserInput);

    TextView tv_custom_dialog_title = (TextView) promptsView.findViewById(R.id.tv_custom_dialog_title);
    TextView tv_text_dialog = (TextView) promptsView.findViewById(R.id.tv_text_dialog);
    //        ImageView iv_image = (ImageView) promptsView.findViewById(R.id.iv_image);

    tv_custom_dialog_title.setText(title);
    tv_text_dialog.setText(dialogtext);

    // set dialog message
    alertDialogBuilder.setCancelable(true).setPositiveButton("Good one", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            //                EspressoMachine_AlertDialogButtonClicked("Good one", TAG);
            alert("You have chosen, Wisely. ");
            Intent intent = new Intent(getBaseContext(), FieldOfFieldsActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                startActivity(intent);
            }
            dialog.cancel();

        }
    })
            //                    public void onClick(DialogInterface dialog, int id) {     EspressoAlertDialogButtonClicked();
            //                        // get user input and set it to result
            //                        // edit text
            //                        if (!userInput.getText().toString().equals("demo") && userInput.getText().toString().equals(getprefPassword(getBaseContext()))) {
            //
            //                        } else { alert("Password incorrect");}
            //
            //                    }
            //                })
            //                .setNeutralButton("Gallery", new DialogInterface.OnClickListener() {
            //                    public void onClick(DialogInterface dialog, int id) {     EspressoAlertDialogButtonClicked();
            //                        // get user input and set it to result
            //                        // edit text
            //                        if (!userInput.getText().toString().equals("demo") && userInput.getText().toString().equals(getprefPassword(getBaseContext()))) {
            //
            //                        } else { alert("Password incorrect");}
            //
            //                    }
            //                })
            .setNegativeButton("BAD QA", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    //                        EspressoMachine_AlertDialogButtonClicked("Bad QA", TAG);
                    alert("You have chosen, Poorly! ");
                    dialog.cancel();
                }
            });

    // create alert dialog
    AlertDialog alertDialog = alertDialogBuilder.create();

    // show it
    alertDialog.show();

    alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(final DialogInterface dialog) {
            Button negativeButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEGATIVE);
            Button positiveButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_POSITIVE);
            Button neutralButton = ((AlertDialog) dialog).getButton(DialogInterface.BUTTON_NEUTRAL);

            // this not working because multiplying white background (e.g. Holo Light) has no effect
            //negativeButton.getBackground().setColorFilter(0xFFFF0000, PorterDuff.Mode.MULTIPLY);

            //                final Drawable negativeButtonDrawable = getResources().getDrawable(R.color.btn_background);
            final Drawable positiveButtonDrawable = getResources().getDrawable(R.color.btn_background);
            //                final Drawable neutralButtonDrawable = getResources().getDrawable(R.color.btn_background);

            //                negativeButton.setBackground(negativeButtonDrawable);
            //        positiveButton.setBackground(positiveButtonDrawable);
            //                neutralButton.setBackground(neutralButtonDrawable);
        }
    });

}

From source file:net.sourceforge.kalimbaradio.androidapp.activity.DownloadActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    if (id == DIALOG_SAVE_PLAYLIST) {
        AlertDialog.Builder builder;/*ww w .ja v a  2  s .  c o m*/

        LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
        final View layout = inflater.inflate(R.layout.save_playlist,
                (ViewGroup) findViewById(R.id.save_playlist_root));
        playlistNameView = (EditText) layout.findViewById(R.id.save_playlist_name);

        builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.download_playlist_title);
        builder.setMessage(R.string.download_playlist_name);
        builder.setPositiveButton(R.string.common_save, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                savePlaylistInBackground(String.valueOf(playlistNameView.getText()));
            }
        });
        builder.setNegativeButton(R.string.common_cancel, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
        builder.setView(layout);
        builder.setCancelable(true);

        return builder.create();
    } else {
        return super.onCreateDialog(id);
    }
}

From source file:com.piusvelte.sonet.core.SonetCreatePost.java

protected void getPhoto(Uri uri) {
    final ProgressDialog loadingDialog = new ProgressDialog(this);
    final AsyncTask<Uri, Void, String> asyncTask = new AsyncTask<Uri, Void, String>() {
        @Override/*  w w w . jav a  2 s. com*/
        protected String doInBackground(Uri... imgUri) {
            String[] projection = new String[] { MediaStore.Images.Media.DATA };
            String path = null;
            Cursor c = getContentResolver().query(imgUri[0], projection, null, null, null);
            if ((c != null) && c.moveToFirst()) {
                path = c.getString(c.getColumnIndex(projection[0]));
            } else {
                // some file manages send the path through the uri
                path = imgUri[0].getPath();
            }
            c.close();
            return path;
        }

        @Override
        protected void onPostExecute(String path) {
            if (loadingDialog.isShowing())
                loadingDialog.dismiss();
            if (path != null)
                setPhoto(path);
            else
                (Toast.makeText(SonetCreatePost.this, "error retrieving the photo path", Toast.LENGTH_LONG))
                        .show();
        }
    };
    loadingDialog.setMessage(getString(R.string.loading));
    loadingDialog.setCancelable(true);
    loadingDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            if (!asyncTask.isCancelled())
                asyncTask.cancel(true);
        }
    });
    loadingDialog.setButton(ProgressDialog.BUTTON_NEGATIVE, getString(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
    loadingDialog.show();
    asyncTask.execute(uri);
}

From source file:ar.com.tristeslostrestigres.diasporanativewebapp.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    int id = item.getItemId();

    if (id == R.id.notifications) {

        if (Helpers.isOnline(MainActivity.this)) {

            //                webView.stopLoading();
            ////from w  w  w .  j  a  v a 2  s. co m
            //                WebView wvNotifications = new WebView(MainActivity.this);
            //                wvNotifications.loadUrl("https://" + podDomain + "/notifications");
            //
            //                final AlertDialog d = new AlertDialog.Builder(MainActivity.this).setView(wvNotifications)
            //                        .setPositiveButton("Close", new DialogInterface.OnClickListener() {
            //                            @TargetApi(11)
            //                            public void onClick(DialogInterface dialog, int id) {
            //                                dialog.cancel();
            //                            }
            //                        }).show();
            //
            ////                wvNotifications.setWebChromeClient(new WebChromeClient() {
            ////
            ////                   public void onProgressChanged(WebView view, int progress) {
            ////                       progressBar.setProgress(progress);
            //
            ////                       if (progress > 0 && progress <= 60) {
            ////                           view.loadUrl("javascript: ( function() {" +
            ////                                   "    if (document.getElementById('notification')) {" +
            ////                                   "       var count = document.getElementById('notification').innerHTML;" +
            ////                                   "       NotificationCounter.setNotificationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
            ////                                   "    } else {" +
            ////                                   "       NotificationCounter.setNotificationCount('0');" +
            ////                                   "    }" +
            ////                                   "    if (document.getElementById('conversation')) {" +
            ////                                   "       var count = document.getElementById('conversation').innerHTML;" +
            ////                                   "       NotificationCounter.setConversationCount(count.replace(/(\\r\\n|\\n|\\r)/gm, \"\"));" +
            ////                                   "    } else {" +
            ////                                   "       NotificationCounter.setConversationCount('0');" +
            ////                                   "    }" +
            ////                                   "})();");
            ////                       }
            //
            ////                       if (progress > 60) {
            ////                           view.loadUrl("javascript: ( function() {" +
            ////                                   "    if(document.getElementById('main_nav')) {" +
            ////                                   "        document.getElementById('main_nav').parentNode.removeChild(" +
            ////                                   "        document.getElementById('main_nav'));" +
            ////                                   "    } else if (document.getElementById('main-nav')) {" +
            ////                                   "        document.getElementById('main-nav').parentNode.removeChild(" +
            ////                                   "        document.getElementById('main-nav'));" +
            ////                                   "    }" +
            ////                                   "})();");
            //////                           fab.setVisibility(View.VISIBLE);
            ////                       }
            //
            ////                       if (progress == 100) {
            ////                           fab.collapse();
            ////                           progressBar.setVisibility(View.GONE);
            ////                       } else {
            ////                           progressBar.setVisibility(View.VISIBLE);
            ////                       }
            ////                   }
            ////               });
            //
            //                        wvNotifications.setWebViewClient(new WebViewClient() {
            //                            @Override
            //                            public boolean shouldOverrideUrlLoading(WebView view, String url) {
            //                                if (!url.equals("https://" + podDomain + "/notifications")) {
            //                                    Intent urlIntent = new Intent(MainActivity.URL_MESSAGE);
            //                                    urlIntent.putExtra("url", url);
            //                                    sendBroadcast(urlIntent);
            //                                }
            //                                d.dismiss();
            //                                return true;
            //                            }
            //                        });

            webView.loadUrl("https://" + podDomain + "/notifications");
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.conversations) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.loadUrl("https://" + podDomain + "/conversations");
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.search) {
        fab.collapse();
        if (Helpers.isOnline(MainActivity.this)) {
            final AlertDialog.Builder alert = new AlertDialog.Builder(this);
            final EditText input = new EditText(this);
            alert.setView(input);
            alert.setTitle(R.string.search_alert_title);
            alert.setPositiveButton(R.string.search_alert_people, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String inputTag = input.getText().toString().trim();
                    String cleanTag = inputTag.replaceAll("\\*", "");
                    // this validate the input data for tagfind
                    if (cleanTag.isEmpty()) {
                        dialog.cancel(); // if user dont have added a tag
                        Snackbar.make(getWindow().findViewById(R.id.drawer),
                                R.string.search_alert_bypeople_validate_needsomedata, Snackbar.LENGTH_LONG)
                                .show();
                    } else { // User have added a search tag
                        txtTitle.setText(R.string.fab1_title_person);
                        webView.loadUrl("https://" + podDomain + "/people.mobile?q=" + cleanTag);
                    }
                }
            }).setNegativeButton(R.string.search_alert_tag, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    String inputTag = input.getText().toString().trim();
                    String cleanTag = inputTag.replaceAll("\\#", "");
                    // this validate the input data for tagfind
                    if (cleanTag.isEmpty()) {
                        dialog.cancel(); // if user hasn't added a tag
                        Snackbar.make(getWindow().findViewById(R.id.drawer),
                                R.string.search_alert_bytags_validate_needsomedata, Snackbar.LENGTH_LONG)
                                .show();
                    } else { // User have added a search tag
                        txtTitle.setText(R.string.fab1_title_tag);
                        webView.loadUrl("https://" + podDomain + "/tags/" + cleanTag);
                    }
                }
            }).setNeutralButton("Cancel", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    //
                }
            });
            alert.show();
        }
    }

    if (id == R.id.reload) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.reload();
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.mobile) {
        if (Helpers.isOnline(MainActivity.this)) {
            webView.loadUrl("https://" + podDomain + "/mobile/toggle");
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.loadImg) {
        if (Helpers.isOnline(MainActivity.this)) {
            wSettings.setLoadsImagesAutomatically(!pm.getLoadImages());
            pm.setLoadImages(!pm.getLoadImages());
            webView.loadUrl(webView.getUrl());
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.fontSize) {
        if (Helpers.isOnline(MainActivity.this)) {
            alertFormElements();
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    if (id == R.id.exit) {
        if (Helpers.isOnline(MainActivity.this)) {
            new AlertDialog.Builder(this).setIcon(android.R.drawable.ic_dialog_alert)
                    .setMessage(getString(R.string.confirm_sign_out))
                    .setPositiveButton(getString(android.R.string.yes).toUpperCase(),
                            new DialogInterface.OnClickListener() {
                                @Override
                                public void onClick(DialogInterface dialog, int which) {
                                    webView.clearCache(true);
                                    Intent i = new Intent(MainActivity.this, PodsActivity.class);
                                    i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
                                    startActivity(i);
                                    finish();
                                }
                            })
                    .setNegativeButton(getString(android.R.string.no).toUpperCase(), null).show();
            return true;
        } else {
            Snackbar.make(getWindow().findViewById(R.id.drawer), R.string.no_internet, Snackbar.LENGTH_SHORT)
                    .show();
            return false;
        }
    }

    return super.onOptionsItemSelected(item);
}

From source file:com.rsltc.profiledata.main.MainActivity.java

private void showSaveDialog(final List<JSONObject> jsonObjectList) {
    AlertDialog.Builder builder = new AlertDialog.Builder(thisActivity);
    builder.setTitle("Dataset title");

    final EditText input = new EditText(thisActivity);
    input.setInputType(InputType.TYPE_CLASS_TEXT);
    builder.setView(input);//w w w . jav a2  s  .c  o  m

    builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final String m_Text = input.getText().toString();
            Runnable r = new Runnable() {
                @Override
                public void run() {
                    exportFile(jsonObjectList, m_Text);
                }
            };

            Thread t = new Thread(r);
            t.start();
        }
    });
    builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });

    builder.show();
}