Example usage for android.app AlertDialog show

List of usage examples for android.app AlertDialog show

Introduction

In this page you can find the example usage for android.app AlertDialog show.

Prototype

public void show() 

Source Link

Document

Start the dialog and display it on screen.

Usage

From source file:com.github.sgelb.booket.SearchResultActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_results);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    noResults = (TextView) findViewById(R.id.noResultsTextView);
    defaultThumbnail = BitmapFactory.decodeResource(getResources(), R.drawable.ic_default_cover);

    bookList = new ArrayList<>();
    resultList = (ListView) findViewById(R.id.searchResultsList);
    downloadProgressBar = (ProgressBar) findViewById(R.id.downloadProgressBar);
    datasource = new BooksDataSource(this);

    BookInfos bookInfos = new BookInfos();
    bookInfos.execute(createUrl());//from   w ww .j  a v a2 s  .c o m
    adapter = new BookResultAdapter(bookList, this);
    resultList.setAdapter(adapter);

    // Save book in database
    resultList.setOnItemLongClickListener(new OnItemLongClickListener() {
        @Override
        public boolean onItemLongClick(AdapterView<?> parent, View view, final int position, long id) {

            AlertDialog alert = new AlertDialog.Builder(SearchResultActivity.this).create();
            alert.setTitle(
                    Html.fromHtml(getString(R.string.dialog_save_book, bookList.get(position).getTitle())));
            alert.setButton(DialogInterface.BUTTON_POSITIVE, getString(R.string.ok), new OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {
                    saveBook(position);
                }
            });
            alert.setButton(DialogInterface.BUTTON_NEGATIVE, getString(R.string.cancel), new OnClickListener() {
                public void onClick(final DialogInterface dialog, final int which) {
                }
            });
            alert.show();

            return true;
        }
    });

    // Expand list row
    resultList.setOnItemClickListener(new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            adapter.toggleExpand(view, position);
        }
    });

}

From source file:com.otaupdater.OTAUpdaterActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Context context = getApplicationContext();
    cfg = Config.getInstance(context);/* ww w  .  j  a v a  2s  .co m*/

    if (!cfg.hasProKey()) {
        bindService(new Intent("com.android.vending.billing.InAppBillingService.BIND"),
                billingSrvConn = new ServiceConnection() {
                    @Override
                    public void onServiceDisconnected(ComponentName name) {
                        billingSrvConn = null;
                    }

                    @Override
                    public void onServiceConnected(ComponentName name, IBinder binder) {
                        IInAppBillingService service = IInAppBillingService.Stub.asInterface(binder);

                        try {
                            Bundle owned = service.getPurchases(3, getPackageName(), "inapp", null);
                            ArrayList<String> ownedItems = owned.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
                            ArrayList<String> ownedItemData = owned
                                    .getStringArrayList("INAPP_PURCHASE_DATA_LIST");

                            if (ownedItems != null && ownedItemData != null) {
                                for (int q = 0; q < ownedItems.size(); q++) {
                                    if (ownedItems.get(q).equals(Config.PROKEY_SKU)) {
                                        JSONObject itemData = new JSONObject(ownedItemData.get(q));
                                        cfg.setKeyPurchaseToken(itemData.getString("purchaseToken"));
                                        break;
                                    }
                                }
                            }
                        } catch (RemoteException ignored) {
                        } catch (JSONException e) {
                            e.printStackTrace();
                        }

                        unbindService(this);
                        billingSrvConn = null;
                    }
                }, Context.BIND_AUTO_CREATE);
    }

    boolean data = Utils.dataAvailable(this);
    boolean wifi = Utils.wifiConnected(this);

    if (!data || !wifi) {
        final boolean nodata = !data && !wifi;

        if ((nodata && !cfg.getIgnoredDataWarn()) || (!nodata && !cfg.getIgnoredWifiWarn())) {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(nodata ? R.string.alert_nodata_title : R.string.alert_nowifi_title);
            builder.setMessage(nodata ? R.string.alert_nodata_message : R.string.alert_nowifi_message);
            builder.setCancelable(false);
            builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    finish();
                }
            });
            builder.setNeutralButton(R.string.alert_wifi_settings, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                    Intent i = new Intent(Settings.ACTION_WIFI_SETTINGS);
                    startActivity(i);
                }
            });
            builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (nodata) {
                        cfg.setIgnoredDataWarn(true);
                    } else {
                        cfg.setIgnoredWifiWarn(true);
                    }
                    dialog.dismiss();
                }
            });

            final AlertDialog dlg = builder.create();

            dlg.setOnShowListener(new DialogInterface.OnShowListener() {
                @Override
                public void onShow(DialogInterface dialog) {
                    onDialogShown(dlg);
                }
            });
            dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
                @Override
                public void onDismiss(DialogInterface dialog) {
                    onDialogClosed(dlg);
                }
            });
            dlg.show();
        }
    }

    Utils.updateDeviceRegistration(this);
    CheckinReceiver.setDailyAlarm(this);

    if (!PropUtils.isRomOtaEnabled() && !PropUtils.isKernelOtaEnabled() && !cfg.getIgnoredUnsupportedWarn()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.alert_unsupported_title);
        builder.setMessage(R.string.alert_unsupported_message);
        builder.setCancelable(false);
        builder.setNegativeButton(R.string.exit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                finish();
            }
        });
        builder.setPositiveButton(R.string.ignore, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                cfg.setIgnoredUnsupportedWarn(true);
                dialog.dismiss();
            }
        });

        final AlertDialog dlg = builder.create();

        dlg.setOnShowListener(new DialogInterface.OnShowListener() {
            @Override
            public void onShow(DialogInterface dialog) {
                onDialogShown(dlg);
            }
        });
        dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
            @Override
            public void onDismiss(DialogInterface dialog) {
                onDialogClosed(dlg);
            }
        });
        dlg.show();
    }

    setContentView(R.layout.main);

    Fragment adFragment = getFragmentManager().findFragmentById(R.id.ads);
    if (adFragment != null)
        getFragmentManager().beginTransaction().hide(adFragment).commit();

    ViewPager mViewPager = (ViewPager) findViewById(R.id.pager);

    bar = getActionBar();
    assert bar != null;

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setTitle(R.string.app_name);

    TabsAdapter mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.main_about), AboutTab.class);

    ActionBar.Tab romTab = bar.newTab().setText(R.string.main_rom);
    if (cfg.hasStoredRomUpdate())
        romTab.setIcon(R.drawable.ic_action_warning);
    romTabIdx = mTabsAdapter.addTab(romTab, ROMTab.class);

    ActionBar.Tab kernelTab = bar.newTab().setText(R.string.main_kernel);
    if (cfg.hasStoredKernelUpdate())
        kernelTab.setIcon(R.drawable.ic_action_warning);
    kernelTabIdx = mTabsAdapter.addTab(kernelTab, KernelTab.class);

    if (!handleNotifAction(getIntent())) {
        if (cfg.hasStoredRomUpdate() && !cfg.isDownloadingRom()) {
            cfg.getStoredRomUpdate().showUpdateNotif(this);
        }

        if (cfg.hasStoredKernelUpdate() && !cfg.isDownloadingKernel()) {
            cfg.getStoredKernelUpdate().showUpdateNotif(this);
        }

        if (savedInstanceState != null) {
            bar.setSelectedNavigationItem(savedInstanceState.getInt(KEY_TAB, 0));
        }
    }
}

From source file:com.balakrish.gpstracker.WaypointsListActivity.java

/**
 * Imports waypoints from gpx file/*  w ww. ja  v  a2  s  .  co m*/
 */
protected void importFromXMLFile() {

    File importFolder = new File(app.getAppDir() + "/" + Constants.PATH_WAYPOINTS);

    final String importFiles[] = importFolder.list();

    if (importFiles == null || importFiles.length == 0) {
        Toast.makeText(WaypointsListActivity.this, "Import folder is empty", Toast.LENGTH_SHORT).show();
        return;
    }

    // first file is preselected
    // TODO: remove class variable
    importWaypointsFileName = importFiles[0];

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

    builder.setSingleChoiceItems(importFiles, 0, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int whichButton) {
            importWaypointsFileName = importFiles[whichButton];
        }
    })

            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int id) {

                    try {

                        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                        DocumentBuilder db = dbf.newDocumentBuilder();
                        File file = new File(app.getAppDir() + "/" + Constants.PATH_WAYPOINTS,
                                importWaypointsFileName);

                        Document doc = db.parse(file);
                        doc.getDocumentElement().normalize();

                        NodeList waypointsList = doc.getElementsByTagName("wpt");

                        boolean updateRequired = false;

                        for (int i = 0; i < waypointsList.getLength(); i++) {

                            Waypoint wp = new Waypoint();

                            wp.setLat(
                                    Double.parseDouble(((Element) waypointsList.item(i)).getAttribute("lat")));
                            wp.setLng(
                                    Double.parseDouble(((Element) waypointsList.item(i)).getAttribute("lon")));

                            Node item = waypointsList.item(i);

                            NodeList properties = item.getChildNodes();
                            for (int j = 0; j < properties.getLength(); j++) {

                                Node property = properties.item(j);
                                String name = property.getNodeName();

                                if (name.equalsIgnoreCase("ELE") && property.getFirstChild() != null) {
                                    wp.setElevation(
                                            Double.parseDouble(property.getFirstChild().getNodeValue()));
                                }
                                if (name.equalsIgnoreCase("TIME") && property.getFirstChild() != null) {
                                    wp.setTime((new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'"))
                                            .parse(property.getFirstChild().getNodeValue()).getTime());
                                }
                                if (name.equalsIgnoreCase("NAME") && property.getFirstChild() != null) {
                                    wp.setTitle(property.getFirstChild().getNodeValue());
                                }

                                if (name.equalsIgnoreCase("DESC") && property.getFirstChild() != null) {
                                    wp.setDescr(property.getFirstChild().getNodeValue());
                                }

                            }

                            // adding imported waypoint to db
                            if (!inWaypointsArray(wp.getTitle())) {

                                try {

                                    Waypoints.insert(app.getDatabase(), wp);

                                    // if at least one record added, update waypoints list
                                    updateRequired = true;

                                } catch (SQLiteException e) {
                                    Log.e(Constants.TAG, "SQLiteException: " + e.getMessage(), e);
                                }

                            }

                        }

                        if (updateRequired) {
                            updateWaypointsArray();
                            waypointsArrayAdapter.setItems(waypoints);
                            waypointsArrayAdapter.notifyDataSetChanged();
                        }

                        Toast.makeText(WaypointsListActivity.this, R.string.import_completed,
                                Toast.LENGTH_SHORT).show();

                    } catch (IOException e) {
                        AppLog.e(WaypointsListActivity.this, e.getMessage());
                    } catch (ParserConfigurationException e) {
                        AppLog.e(WaypointsListActivity.this, e.getMessage());
                    } catch (ParseException e) {
                        AppLog.e(WaypointsListActivity.this, e.getMessage());
                    } catch (SAXException e) {
                        AppLog.e(WaypointsListActivity.this, e.getMessage());
                    }

                    dialog.dismiss();
                }
            })

            .setTitle(R.string.select_file).setCancelable(true);

    AlertDialog alert = builder.create();

    alert.show();

}

From source file:org.thoughtland.xlocation.ActivityShare.java

@SuppressLint("InflateParams")
public static boolean registerDevice(final ActivityBase context) {
    int userId = Util.getUserId(Process.myUid());
    if (Util.hasProLicense(context) == null
            && !PrivacyManager.getSettingBool(userId, PrivacyManager.cSettingRegistered, false)) {
        // Get accounts
        String email = null;//from w  w  w .jav  a2  s. com
        for (Account account : AccountManager.get(context).getAccounts())
            if ("com.google".equals(account.type)) {
                email = account.name;
                break;
            }

        LayoutInflater LayoutInflater = (LayoutInflater) context
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View view = LayoutInflater.inflate(R.layout.register, null);
        final EditText input = (EditText) view.findViewById(R.id.etEmail);
        if (email != null)
            input.setText(email);

        // Build dialog
        AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
        alertDialogBuilder.setTitle(R.string.msg_register);
        alertDialogBuilder.setIcon(context.getThemed(R.attr.icon_launcher));
        alertDialogBuilder.setView(view);
        alertDialogBuilder.setPositiveButton(context.getString(android.R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        String email = input.getText().toString();
                        if (Patterns.EMAIL_ADDRESS.matcher(email).matches())
                            new RegisterTask(context).executeOnExecutor(mExecutor, email);
                    }
                });
        alertDialogBuilder.setNegativeButton(context.getString(android.R.string.cancel),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Do nothing
                    }
                });

        // Show dialog
        AlertDialog alertDialog = alertDialogBuilder.create();
        alertDialog.show();

        return false;
    }
    return true;
}

From source file:gr.scify.newsum.ui.ViewActivity.java

private void Copy() {
    //      TextView tx = (TextView) findViewById(R.id.textView1);
    TextView title = (TextView) findViewById(R.id.title);
    String sdtitle = title.getText().toString();
    //      String copytext = tx.getText().toString();
    String alphaAndDigits = sdtitle.replaceAll("[^\\p{L}\\p{N}]", " ");
    Boolean isSDPresent = android.os.Environment.getExternalStorageState()
            .equals(android.os.Environment.MEDIA_MOUNTED);

    // track the copy to SD event
    if (getAnalyticsPref()) {
        EasyTracker.getTracker().sendEvent(SHARING_ACTION, "Save to SD", title.getText().toString(), 0l);
    }//from ww  w  .j  a  v a  2s  .co  m
    if (isSDPresent) {
        File folder = new File(Environment.getExternalStorageDirectory() + "/NewSum");
        boolean success = false;
        if (!folder.exists()) {
            success = folder.mkdir();
        }
        if (!success) {
            // Do something on success
        } else {
            // Do something else on failure
        }
        File logFile = new File(folder, alphaAndDigits + ".txt");
        // File logFile = new
        // File(Environment.getExternalStorageDirectory().toString(),
        // alphaAndDigits+".txt");
        if (!logFile.exists()) {
            try {
                logFile.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

        BufferedWriter output = null;
        try {
            output = new BufferedWriter(new FileWriter(logFile));
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {
            output.write(pText);
        } catch (IOException e) {
            e.printStackTrace();
        }
        try {

            output.close();
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.setTitle(R.string.save_massage);
            builder.setMessage(logFile.getPath());
            builder.setPositiveButton(getResources().getText(R.string.ok).toString(),
                    new DialogInterface.OnClickListener() {

                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            dialog.dismiss();
                        }
                    });
            AlertDialog a = builder.create();
            a.show();
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else {
        Toast.makeText(ViewActivity.this, R.string.check_sd, Toast.LENGTH_SHORT).show();
    }

}

From source file:com.transistorsoft.cordova.bggeo.CDVBackgroundGeolocation.java

private void onError(String error) {
    String message = "BG Geolocation caught a Javascript exception while running in background-thread:\n"
            .concat(error);//  w w w. j av  a 2 s  . c  om
    Log.e(TAG, message);

    // Show alert popup with js error
    if (isDebugging()) {
        playSound(68);
        AlertDialog.Builder builder = new AlertDialog.Builder(this.cordova.getActivity());
        builder.setMessage(message).setCancelable(false).setNegativeButton("OK",
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        //do things
                    }
                });
        AlertDialog alert = builder.create();
        alert.show();
    }
}

From source file:com.safecell.HomeScreenActivity.java

public void showGPSStatusAlert(String provider) {

    // Log.v("Safecell", "" + provider);

    String title = "";
    String message = "";

    if (LocationManager.GPS_PROVIDER.equals(provider)) {
        return;/*from  w  ww. j av a2 s  .  com*/
    }

    if (provider == null) {
        title = "GPS is not enabled.";
        message = "GPS is not enabled. Please enable it.";
    } else {
        title = "GPS is not enabled.";
        message = "GPS is not enabled. Please enable it. \nMeanwhile, background trip tracking will be disabled.";
    }

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

    builder.setTitle(title);
    builder.setMessage(message);
    builder.setCancelable(false);

    builder.setPositiveButton("Launch Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            launchGPSOptions();
        }
    });

    if (LocationManager.NETWORK_PROVIDER.equals(provider)) {
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                dialog.cancel();
            }
        });
    }

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

From source file:fm.smart.r1.ItemActivity.java

public void addToList(final String item_id) {
    final ProgressDialog myOtherProgressDialog = new ProgressDialog(this);
    myOtherProgressDialog.setTitle("Please Wait ...");
    myOtherProgressDialog.setMessage("Adding item to study goal ...");
    myOtherProgressDialog.setIndeterminate(true);
    myOtherProgressDialog.setCancelable(true);

    final Thread add = new Thread() {
        public void run() {
            ItemActivity.add_item_result = new AddItemResult(
                    Main.lookup.addItemToGoal(Main.transport, Main.default_study_goal_id, item_id, null));

            myOtherProgressDialog.dismiss();
            ItemActivity.this.runOnUiThread(new Thread() {
                public void run() {
                    final AlertDialog dialog = new AlertDialog.Builder(ItemActivity.this).create();
                    dialog.setTitle(ItemActivity.add_item_result.getTitle());
                    dialog.setMessage(ItemActivity.add_item_result.getMessage());
                    ItemActivity.add_item_result = null;
                    dialog.setButton("OK", new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                        }//from   w w  w.  j  av a2s.c o  m
                    });

                    dialog.show();
                }
            });

        }
    };
    myOtherProgressDialog.setButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            add.interrupt();
        }
    });
    OnCancelListener ocl = new OnCancelListener() {
        public void onCancel(DialogInterface arg0) {
            add.interrupt();
        }
    };
    myOtherProgressDialog.setOnCancelListener(ocl);
    closeMenu();
    myOtherProgressDialog.show();
    add.start();
}

From source file:cm.aptoide.pt.ManageRepo.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.repolist);/*  w  w w .ja  v a  2  s  . c  o m*/

    db = new DbHandler(this);

    Intent i = getIntent();
    if (i.hasExtra("empty")) {
        final String uri = i.getStringExtra("uri");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.myrepo_alrt) + uri);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(uri);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                return;
            }
        });
        alrt.show();
    } else if (i.hasExtra("uri")) {
        String uri = i.getStringExtra("uri");
        Vector<String> new_serv_lst = getRemoteServLst(uri);
        for (final String srv : new_serv_lst) {
            AlertDialog alrt = new AlertDialog.Builder(this).create();
            alrt.setTitle(getString(R.string.title_repo_alrt));
            alrt.setIcon(android.R.drawable.ic_dialog_alert);
            alrt.setMessage(getString(R.string.newrepo_alrt) + srv);
            alrt.setButton("Yes", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    db.addServer(srv);
                    change = true;
                    redraw();
                    return;
                }
            });
            alrt.setButton2("No", new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    return;
                }
            });
            alrt.show();
        }
    } else if (i.hasExtra("newrepo")) {
        final String repo = i.getStringExtra("newrepo");
        AlertDialog alrt = new AlertDialog.Builder(this).create();
        alrt.setTitle(getString(R.string.title_repo_alrt));
        alrt.setIcon(android.R.drawable.ic_dialog_alert);
        alrt.setMessage(getString(R.string.newrepo_alrt) + repo);
        alrt.setButton("Yes", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                db.addServer(repo);
                change = true;
                redraw();
                return;
            }
        });
        alrt.setButton2("No", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //exit
            }
        });
        alrt.show();
    }
}

From source file:at.alladin.rmbt.android.loopmode.LoopModeTestFragment.java

public boolean onBackPressed() {
    if (loopService == null) {
        return false;
    }//from w w w  . ja  va2s  . co  m

    else if (loopService.isRunning() || (loopService.getLoopModeResults().getMaxTests() > loopService
            .getLoopModeResults().getNumberOfTests())) {

        AlertDialog stopDialog = new AlertDialog.Builder(getActivity())
                .setTitle(R.string.test_dialog_abort_title).setMessage(R.string.loop_mode_test_dialog_abort)
                .setPositiveButton(android.R.string.yes, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        stopLoopService();
                        ((RMBTMainActivity) getActivity()).popBackStackFull();
                    }
                }).setNegativeButton(android.R.string.no, new OnClickListener() {

                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                }).create();

        stopDialog.setCancelable(false);
        stopDialog.show();
    } else if (loopService.getLoopModeResults().getMaxTests() <= loopService.getLoopModeResults()
            .getNumberOfTests()) {
        //if max tests is reached simply remove this fragment without alert dialog
        stopLoopService();
        return false;
    }

    return true;
}