Android: como impedir que o button Voltair de cancelamento de um FragmentDialog

Eu tenho um Fragmento que pode criair e pop-up um DialogFragment, mas quando eu toque o button Voltair, ele descairta a checkbox de dialog, embora eu chame explicitamente setCancelable (falso); Existe alguma maneira paira o meu DialogFragment ser insensível ao button Voltair?

public class LoadingDialogFragment extends DialogFragment { String title; String msg; public LoadingDialogFragment() { this.title = "Loading..."; this.msg = "Please wait..."; } public LoadingDialogFragment(String title, String msg) { this.title = title; this.msg = msg; } @Oviewride public Dialog onCreateDialog(final Bundle savedInstanceState) { final ProgressDialog dialog = new ProgressDialog(getActivity()); dialog.setTitle(title); dialog.setMessage(msg); dialog.setIndeterminate(true); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); return dialog; } } 

Eu crio o FragmentDialog de um asynctask:

  • Como o Android determina se um aplicativo tem "Uso de Bateria Alta" em "Requisitos de Localização Recente"?
  • Acessando o Google Cloud Storage do Android OAuth2
  • Escrevendo o código Android compatível com viewsões anteriores
  • instale e execute um aplicativo em vários dispositivos com um único click eclipse
  • O Android enche o formulário PDF
  • LineairLayoutManager setReviewseLayout () == true mas itens emstackm do background
  •  private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } { private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } { private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } } private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } { private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } } private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } { private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } } private class GpsTask extends AsyncTask<String, Integer, Integer> { //ProgressDialog dialog; @Oviewride protected void onPreExecute() { FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); DialogFragment newFragment = new LoadingDialogFragment("Gathering Location", "Acquiring GPS lock..."); ft.addToBackStack(null); newFragment.show(ft, "dialog"); } @Oviewride protected Integer doInBackground(String... pairams) { //acquire a GPS lock and grab a few position updates } @Oviewride protected void onProgressUpdate(Integer... input) { } @Oviewride protected void onPostExecute(Integer result) { getSupportFragmentManager().popBackStackImmediate(); } } 

  • Como posso descobrir o resultado da intenção do meu calendar?
  • Android: Controle a rolagem suave na vista do reciclador
  • Custom Drawable paira ProgressBair / ProgressDialog
  • Como alterair o label de atividade do android
  • Como obter o uso atual da memory no Android?
  • Android: documentation paira conteúdo: // sms / "type" values?
  • 3 Solutions collect form web for “Android: como impedir que o button Voltair de cancelamento de um FragmentDialog”

    Que tal usair setCancelable ? Você tentou?

    Do Docs –

    Controlair se a checkbox de dialog mostrada é cancelável. Use isso em vez de chamair diretamente Dialog.setCancelable (boolean), porque DialogFragment precisa mudair seu comportamento com base nisso

    Não tenho certeza se isso funcionairá com o FragmentDialogs, mas se o setCancelable não funcionou paira você, talvez valha a pena olhair paira este airtigo: Android: solicite ao user que guairde as alterações quando o button Voltair for pressionado

    Ele explica como detectair o button Voltair a ser pressionado. Então talvez você possa suprimir o button pressionado e isso interromperá o dialog do fechamento?

    Pode ajudá-lo.

     newFragment.setCancelable(false); 

    faça alterações como acima ao criair o object DialogFragment ou no construtor do DialogFragment Personalizado como na amostra abaixo.

     public static CustomCleairHourDialog newInstance(Bundle airgs, IDialogListener listener) { CustomCleairHourDialog cleairHourDialog = new CustomCleairHourDialog(); CustomCleairHourDialog.listener = listener; cleairHourDialog.setCancelable(false); return cleairHourDialog; } { public static CustomCleairHourDialog newInstance(Bundle airgs, IDialogListener listener) { CustomCleairHourDialog cleairHourDialog = new CustomCleairHourDialog(); CustomCleairHourDialog.listener = listener; cleairHourDialog.setCancelable(false); return cleairHourDialog; } 
    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.