Example usage for android.app ProgressDialog STYLE_SPINNER

List of usage examples for android.app ProgressDialog STYLE_SPINNER

Introduction

In this page you can find the example usage for android.app ProgressDialog STYLE_SPINNER.

Prototype

int STYLE_SPINNER

To view the source code for android.app ProgressDialog STYLE_SPINNER.

Click Source Link

Document

Creates a ProgressDialog with a circular, spinning progress bar.

Usage

From source file:com.zirconi.huaxiaclient.LoginActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_layout);
    application = (SharedApplication) this.getApplication();
    pref = getSharedPreferences("LOGIN", MODE_PRIVATE);
    PAGE = SharedApplication.TEL_PAGE;/*from  www  .  j a va2  s.co m*/
    INDEXPAGE = SharedApplication.HTTP_TEL_ADDR;
    runFlag = false;
    AUTHOR = (TextView) this.findViewById(R.id.author);
    AUTHOR.setText(AUT);

    this.login_et_username = (EditText) this.findViewById(R.id.login_et_username);
    this.login_et_password = (EditText) this.findViewById(R.id.login_et_password);
    this.login_cb_rempwd = (CheckBox) this.findViewById(R.id.login_cb_rempwd);
    this.login_rb_tel = (RadioButton) this.findViewById(R.id.login_rb_tel);
    this.login_rb_cer = (RadioButton) this.findViewById(R.id.login_rb_cer);
    this.login_btn_submit = (Button) this.findViewById(R.id.login_btn_submit);
    this.login_btn_cancel = (Button) this.findViewById(R.id.login_btn_cancel);
    this.login_rg_select = (RadioGroup) this.findViewById(R.id.login_rg_select);

    if (pref.getBoolean("TEL", true)) {
        this.login_rb_tel.setChecked(true);
        PAGE = SharedApplication.TEL_PAGE;
        INDEXPAGE = SharedApplication.HTTP_TEL_ADDR;
    } else {
        this.login_rb_cer.setChecked(true);
        PAGE = SharedApplication.CER_PAGE;
        INDEXPAGE = SharedApplication.HTTP_CER_ADDR;
    }

    if (pref.getBoolean("PASSWORD", false)) {
        this.login_cb_rempwd.setChecked(true);
    } else {
        this.login_cb_rempwd.setChecked(false);
    }

    if (this.login_cb_rempwd.isChecked() && !pref.getString("user", "").equals("")) {
        this.login_et_username.setText(pref.getString("user", ""));
        this.login_et_password.setText(pref.getString("pwd", ""));
    }

    this.login_cb_rempwd.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            if (isChecked) {
                Editor tmp = pref.edit();
                tmp.putBoolean("PASSWORD", true);
                tmp.commit();
            } else {
                Editor tmp = pref.edit();
                tmp.putBoolean("PASSWORD", false);
                tmp.putString("user", "");
                tmp.putString("pwd", "");
                tmp.commit();
            }
        }
    });

    this.login_rg_select.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
        public void onCheckedChanged(RadioGroup group, int checkedId) {
            if (checkedId == R.id.login_rb_cer) {
                Editor tmp = pref.edit();
                tmp.putBoolean("TEL", false);
                tmp.commit();
                PAGE = SharedApplication.CER_PAGE;
                INDEXPAGE = SharedApplication.HTTP_CER_ADDR;
                Log.d(TAG, "SLELCT CER " + PAGE);
            } else {
                Editor tmp = pref.edit();
                tmp.putBoolean("TEL", true);
                tmp.commit();
                PAGE = SharedApplication.TEL_PAGE;
                INDEXPAGE = SharedApplication.HTTP_TEL_ADDR;
                Log.d(TAG, "SLELCT TEL " + PAGE);
            }
        }
    });

    this.login_btn_cancel.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            LoginActivity.this.finish();
        }
    });

    this.login_btn_submit.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            if (login_et_username.getText().toString().equals("")
                    || login_et_password.getText().toString().equals("")) {
                Toast.makeText(LoginActivity.this, "", Toast.LENGTH_LONG).show();
            } else {
                if (login_cb_rempwd.isChecked()) {
                    Editor tmp = pref.edit();
                    tmp.putString("user", login_et_username.getText().toString());
                    tmp.putString("pwd", login_et_password.getText().toString());
                    tmp.commit();

                    isNetwork = SharedApplication.networkIsAvailable(LoginActivity.this);
                    if (isNetwork) {
                        if (runFlag == false) {
                            t = new ProgressDialog(LoginActivity.this);
                            t.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                            t.setTitle("");
                            t.setMessage("");
                            t.show();
                            TASK = new Async();
                            TASK.execute(PAGE);
                            runFlag = true;
                        }
                    } else {
                        Toast.makeText(LoginActivity.this, "", Toast.LENGTH_LONG).show();
                    }
                } else {
                    // 
                    isNetwork = SharedApplication.networkIsAvailable(LoginActivity.this);
                    if (isNetwork) {
                        if (runFlag == false) {
                            t = new ProgressDialog(LoginActivity.this);
                            t.setProgressStyle(ProgressDialog.STYLE_SPINNER);
                            t.setTitle("");
                            t.setMessage("");
                            t.show();
                            TASK = new Async();
                            TASK.execute(PAGE);
                            runFlag = true;
                        }
                    } else {
                        Toast.makeText(LoginActivity.this, "", Toast.LENGTH_LONG).show();
                    }
                }
            }
        }
    });
    Log.i(TAG, "ONCREATE");
}

From source file:net.vivekiyer.GAL.Configure.java

/**
 * Validates the user entries and connects to the Exchange server 
 *///from  w ww.ja  va2s.c o m
private void connect() {
    // Make sure that the user has entered the username
    // password and the server name
    if (getTextFromId(R.id.txtDomainUserName).equals("")) { //$NON-NLS-1$
        showAlert(getString(R.string.valid_domain_and_username_error));
        return;
    }

    String[] splits = getTextFromId(R.id.txtDomainUserName).split("\\\\"); //$NON-NLS-1$

    if (splits.length == 1) {
        domain = ""; //$NON-NLS-1$
        username = splits[0];
    } else if (splits.length == 2) {
        domain = splits[0];
        username = splits[1];
    } else {
        showAlert(getString(R.string.domain_and_username_format_error));
        return;
    }

    if (username.equalsIgnoreCase("")) { //$NON-NLS-1$
        showAlert(getString(R.string.invalid_username_error));
        return;
    }

    if (getTextFromId(R.id.txtPassword).equalsIgnoreCase("")) { //$NON-NLS-1$
        showAlert(getString(R.string.invalid_password_error));
        return;
    }

    if (getTextFromId(R.id.txtServerName).equalsIgnoreCase("")) { //$NON-NLS-1$
        showAlert(getString(R.string.invalid_exchange_url_error));
        return;
    }

    // Now that we have all three
    // Lets validate it   

    activeSyncManager = new ActiveSyncManager(getTextFromId(R.id.txtServerName).trim(), domain, username,
            getTextFromId(R.id.txtPassword), getValueFromCheckbox(R.id.chkUseSSL),
            getValueFromCheckbox(R.id.chkAcceptAllSSLCert), "", //$NON-NLS-1$
            "", //$NON-NLS-1$
            null);

    // If we get an error from Initialize
    // That means the URL is just bad
    // display an error
    if (!activeSyncManager.Initialize()) {
        showAlert(getString(R.string.please_check_settings));
        return;
    }

    progressdialog = new ProgressDialog(this);
    progressdialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    progressdialog.setMessage(getString(R.string.validating_settings));
    progressdialog.setCancelable(false);
    progressdialog.show();
    ConnectionChecker checker = new ConnectionChecker(this);
    checker.execute(activeSyncManager);
}

From source file:com.handpoint.headstart.client.ui.ReceiptActivity.java

/** Called when the activity is first created. */
@Override// ww  w . j a v  a2 s. co m
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.receipt);

    long transactionId = getIntent().getLongExtra(EXTRA_TRANSACTION_ID, -1);
    if (transactionId == -1) {
        finish();
        return;
    }

    DaoHelper daoHelper = new DaoHelper(this);
    daoHelper.open(false);
    mResult = daoHelper.getFinancialTransaction(transactionId);
    Basket basket = daoHelper.getBasketByTransaction(transactionId);
    if (null != basket) {
        mBasketItem = daoHelper.getBasketItem(basket.getId());
    }
    daoHelper.close();
    Button buttonDone = (Button) findViewById(R.id.bottom_button);
    buttonDone.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            finish();
        }
    });

    mRevertButton = (Button) findViewById(R.id.revert_button);
    if ((mResult.getType() == FinancialTransactionResult.FT_TYPE_SALE
            || mResult.getType() == FinancialTransactionResult.FT_TYPE_REFUND)
            && null != mResult.getTransactionId() && mResult.getTransactionId().length() > 0
            && mResult.getTransactionStatus() == TransactionStatus.EFT_TRANSACTION_APPROVED
            && 0 == mResult.getVoidedId()) {
        mRevertButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent startVoidIntent = new Intent(HeadstartService.ACTION_MAIN);
                startVoidIntent.putExtra(HeadstartService.EXTRA_OPERATION_TYPE,
                        mResult.getType() == FinancialTransactionResult.FT_TYPE_SALE
                                ? FinancialTransactionResult.FT_TYPE_SALE_VOID
                                : FinancialTransactionResult.FT_TYPE_REFUND_VOID);
                startVoidIntent.putExtra(HeadstartService.EXTRA_PAYMENT_VALUE, mResult.getAuthorizedAmount());
                startVoidIntent.putExtra(HeadstartService.EXTRA_PAYMENT_CURRENCY, mResult.getCurrency());
                startVoidIntent.putExtra(HeadstartService.EXTRA_PAYMENT_TRANSACTION_ID,
                        mResult.getTransactionId());
                startVoidIntent.putExtra("com.handpoint.headstart.client.VOIDED_ID", mResult.getId());
                startActivity(startVoidIntent);
                finish();
            }
        });
    } else {
        mRevertButton.setVisibility(View.GONE);
    }

    mDetailsButton = (Button) findViewById(R.id.details_button);
    if (!TextUtils.isEmpty(mResult.getMerchantReceipt()) || !TextUtils.isEmpty(mResult.getCustomerReceipt())) {
        mDetailsButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = new Intent(ReceiptActivity.this, RawReceiptActivity.class);
                intent.putExtra("merchantReceipt", mResult.getMerchantReceipt());
                intent.putExtra("customerReceipt", mResult.getCustomerReceipt());
                intent.putExtra("signatureVerificationText", mResult.getSignatureVerificationText());
                intent.putExtra("signatureImage", mResult.getSignaturePath());
                startActivity(intent);
            }
        });
    } else {
        mDetailsButton.setVisibility(View.GONE);
    }

    initReceiptView();

    final ImageView sendEmailView = (ImageView) findViewById(R.id.email_send_image);
    mEmailView = (EditText) findViewById(R.id.email_address);

    final ImageView sendSmsView = (ImageView) findViewById(R.id.sms_send_image);
    mSmsView = (EditText) findViewById(R.id.sms_address);

    sendEmailView.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            hideSoftKeyboard(mEmailView);
            mPdfDlg = new ProgressDialog(v.getContext());
            mPdfDlg.setMessage(getString(R.string.pdf_dlg_msg));
            mPdfDlg.setTitle(getString(R.string.pdf_dlg_title));
            mPdfDlg.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            mPdfDlg.setCancelable(true);
            mPdfDlg.show();

            new Thread(new Runnable() {
                public void run() {
                    ArrayList<File> attachments = null;
                    try {
                        Thread.sleep(1000);
                        attachments = getCustomerEmailAttachments();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    if (attachments != null) {
                        try {
                            Thread.sleep(2000);
                        } catch (InterruptedException e) {
                            e.printStackTrace();
                        }
                        mPdfDlg.dismiss();

                        SenderHelper.MerchantEmailServerSettings serverSettings = new SenderHelper.MerchantEmailServerSettings(
                                ReceiptActivity.this);
                        SendAsyncTask sendTask = new SendAsyncTask();
                        sendTask.execute(new EmailDataHolder(ReceiptActivity.this, serverSettings,
                                mEmailView.getText().toString(), new SpannableString(""), attachments,
                                EmailTypes.CUSTOMER));
                    }
                }
            }).start();
        }
    });

    sendSmsView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            hideSoftKeyboard(mSmsView);
            SenderHelper.sendReceiptSms(ReceiptActivity.this, mSmsView.getText().toString(), mResult);
            //mark customer receipt as "copy"
            markCustomerReceiptAsCopied(ReceiptActivity.this, mResult);
        }
    });

    if (getIntent().getBooleanExtra(EXTRA_SEND_MERCHANT_RECEIPT, false) && savedInstanceState == null) {
        sendMerchantReceipt();
    }

    // repeat image bug fix
    //      View background = findViewById(R.id.rootLayout);
    //      ((BitmapDrawable)background.getBackground()).setTileModeXY(TileMode.REPEAT, TileMode.REPEAT);

    //      getSupportActionBar().setTitle(R.string.abs_title);
    //      getSupportActionBar().setDisplayHomeAsUpEnabled(true);

}

From source file:de.sauernetworks.stm32_bluetooth_flashloader.BluetoothUpdaterFragment.java

private void createDialog(int id) {
    switch (id) {
    case DIALOG_CONNECT_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        mProgressDialog.setMessage("Connecting..");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();//from  ww w  . j  a v a 2s .  c  o  m
        break;
    case DIALOG_ERASE_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        mProgressDialog.setMessage("Erasing Memory..");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();
        break;
    case DIALOG_DOWNLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        mProgressDialog.setMessage("Downloading memory..\n(1/"
                + String.valueOf((STM32_PAGE_COUNT * STM32_BYTE_COUNT) / 1024) + " kb)");
        mProgressDialog.setMax(STM32_PAGE_COUNT);
        mProgressDialog.setProgressNumberFormat("%1d of %2d Pages read");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();
        break;
    case DIALOG_UPLOAD_PROGRESS:
        mProgressDialog = new ProgressDialog(this.getActivity());
        /*if (firmware_upload_size > 1024)
            mProgressDialog.setMessage("Uploading memory..\n(1/"+String.valueOf(firmware_upload_size / 1024)+" kb)");
        else*/
        mProgressDialog
                .setMessage("Uploading memory..\n(1/" + String.valueOf(firmware_upload_size) + " bytes)");
        if ((firmware_upload_size / 256) <= 1)
            mProgressDialog.setMax(1);
        else
            mProgressDialog.setMax((int) (firmware_upload_size / STM32_BYTE_COUNT));
        mProgressDialog.setProgressNumberFormat("%1d of %2d Pages written");
        mProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
        mProgressDialog.setCancelable(false);
        if (!mProgressDialog.isShowing())
            mProgressDialog.show();
        break;
    case DIALOG_START_BOOTLOADER_INFO:
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        builder.setMessage(R.string.dialog_start_bootloader_info_message)
                .setPositiveButton(R.string.dialog_start_bootloader_info_button_start,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                final Handler handler = new Handler();
                                handler.postDelayed(new Runnable() {
                                    @Override
                                    public void run() {
                                        try {
                                            mBootloader.init();
                                        } catch (IOException e) {
                                            Toast.makeText(getActivity(), R.string.toast_error_command_running,
                                                    Toast.LENGTH_SHORT).show();
                                            e.printStackTrace();
                                        }
                                    }
                                }, 500);
                            }
                        })
                .setNegativeButton(R.string.dialog_start_bootloader_info_button_cancel,
                        new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                // User cancelled the dialog
                            }
                        })
                .show();
        break;
    }
}

From source file:org.deviceconnect.android.deviceplugin.sphero.setting.fragment.DeviceSelectionPageFragment.java

@Override
public void onClicked(final int position, final Sphero device) {

    Activity activity = getActivity();//from   w  w  w.  ja v a2  s.  c  o  m
    if (activity == null) {
        return;
    }

    if (device.isConnected()) {
        ((SettingActivity) activity).sendDisonnectBroadcast(device.getUniqueId());
        if (mAdapter.getCount() == 0) {
            // ???????????.
            stopDiscovery();
            startDiscovery();
        }
    } else {
        mIndView = new ProgressDialog(activity);
        mIndView.setMessage(activity.getString(R.string.connecting));
        mIndView.setProgressStyle(ProgressDialog.STYLE_SPINNER);
        mIndView.setCancelable(false);
        mIndView.show();
        ((SettingActivity) activity).sendConnectBroadcast(device.getUniqueId());
    }
}

From source file:com.paramedic.mobshaman.fragments.AccionesDetalleServicioFragment.java

private void initializeUI(View myView) {

    finishRequestParams = new RequestParams();

    btnLlegadaServicio = (Button) myView.findViewById(R.id.btn_llegada_servicio);
    btnSalidaServicio = (Button) myView.findViewById(R.id.btn_salida_servicio);
    btnFinalServicio = (Button) myView.findViewById(R.id.btn_final_servicio);
    btnHistoriaClinica = (Button) myView.findViewById(R.id.btn_hc_paciente_servicio);
    btnCancelarServicio = (Button) myView.findViewById(R.id.btn_cancelacion_servicio);
    btnDistanciaServicio = (Button) myView.findViewById(R.id.btn_distancia_servicio);
    btnAttachImage = (Button) myView.findViewById(R.id.btn_attach_image);

    if (serv.getFlgRename() == 1) {
        btnSalidaServicio.setText("Derivacin");
        btnLlegadaServicio.setText("Internacin");
    }/*from   www. j ava2 s  . c o m*/

    toggleButton(btnLlegadaServicio, serv.getHabLlegada());
    toggleButton(btnSalidaServicio, serv.getHabSalida());
    toggleButton(btnFinalServicio, serv.getHabFinal());
    toggleButton(btnCancelarServicio, serv.getHabCancelacion());

    pDialog = new ProgressDialog(getActivity());
    pDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

}

From source file:com.artur.softwareproject.Main.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.disconnect:

        if (!recording) {
            stopService(bluetoothServiceIntent);

            final ProgressDialog disconnectingDialog = new ProgressDialog(Main.this);

            disconnectingDialog.setMessage("Disconnecting...");
            disconnectingDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
            disconnectingDialog.setCancelable(false);
            disconnectingDialog.show();// w  ww .  ja va 2  s.c  o m

            disconDialog = disconnectingDialog;

            final DisconnectHandlerClass disconnectHandler = new DisconnectHandlerClass(this);

            disconnectThread = new Thread(new Runnable() {
                @Override
                public void run() {
                    int stop = 0;

                    while (stop == 0) {
                        stop = getDisconnect();
                        sleep(1500);
                    }

                    disconnectHandler.sendEmptyMessage(0);
                }
            });

            disconnectThread.start();
        }

        return true;

    case R.id.record_data:

        Log.d(TAG, "Record button was Pressed. Gps status: " + gpsStatus);

        if (!recording && gpsStatus) {
            Intent resetIntent = new Intent();

            resetIntent.putExtra("reset", "");
            resetIntent.setAction("resetFilter");

            LocalBroadcastManager.getInstance(getApplicationContext()).sendBroadcast(resetIntent);

            item.setIcon(R.drawable.ic_action_stop);

            Toast.makeText(getApplicationContext(), "Start recording data", Toast.LENGTH_LONG).show();

            currentTime = System.currentTimeMillis();
            recordClock.setVisibility(View.VISIBLE);

            Animation a = AnimationUtils.loadAnimation(this, R.anim.textslide);
            TextView tv = (TextView) findViewById(R.id.recordClock);

            tv.startAnimation(a);

            recording = true;

            if (!rBound) {
                Intent intent = new Intent(this, RecordService.class);
                bindService(intent, mConnection, Context.BIND_AUTO_CREATE);
            }
        } else if (recording) {
            stopRecording();
        }

        return true;

    case R.id.vr_menu:

        if (!recording) {
            Intent vrIntent = new Intent(Main.this, VRmenuMap.class);
            Main.this.startActivity(vrIntent);
        }

        return true;

    default:

        return super.onOptionsItemSelected(item);
    }
}

From source file:org.ros.android.app_chooser.ExchangeActivity.java

public void uninstallApp(View view) {
    final ExchangeActivity activity = this;
    final ProgressDialog progress = ProgressDialog.show(activity, "Uninstalling App",
            "Uninstalling " + appSelectedDisplay + "...", true, false);
    progress.setProgressStyle(ProgressDialog.STYLE_SPINNER);
    appManager.uninstallApp(appSelected, new ServiceResponseListener<UninstallApp.Response>() {
        @Override/*from www . j a  v  a2s  . c o  m*/
        public void onSuccess(UninstallApp.Response message) {
            if (!message.uninstalled) {
                final String errorMessage = message.message;
                runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        new AlertDialog.Builder(activity).setTitle("Error on Uninstallation!")
                                .setCancelable(false).setMessage("ERROR: " + errorMessage)
                                .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                    }
                                }).create().show();
                    }
                });
            }
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    progress.dismiss();
                }
            });
        }

        @Override
        public void onFailure(final RemoteException e) {
            e.printStackTrace();
            runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    new AlertDialog.Builder(activity).setTitle("Error on Uninstallation").setCancelable(false)
                            .setMessage("Failed: cannot contact robot: " + e.toString())
                            .setNeutralButton("Ok", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dialog, int which) {
                                }
                            }).create().show();
                    progress.dismiss();
                }
            });
        }
    });
}

From source file:ca.rmen.android.networkmonitor.app.log.LogActionsActivity.java

@Override
public void onOkClicked(int actionId, Bundle extras) {
    Log.v(TAG, "onOkClicked, actionId = " + actionId);
    mUserInput = true;/*from   ww w  .j a  va2 s.  c  om*/
    // The user confirmed to clear the logs.
    if (actionId == R.id.action_clear) {
        Log.v(TAG, "Clicked ok to clear log");
        DialogFragmentFactory.showProgressDialog(LogActionsActivity.this,
                getString(R.string.progress_dialog_message), ProgressDialog.STYLE_SPINNER, PROGRESS_DIALOG_TAG);
        AsyncTask<Void, Void, Void> asyncTask = new AsyncTask<Void, Void, Void>() {

            @Override
            protected Void doInBackground(Void... params) {
                Log.v(TAG, "clear:doInBackground");
                getContentResolver().delete(NetMonColumns.CONTENT_URI, null, null);
                return null;
            }

            @Override
            protected void onPostExecute(Void result) {
                // Once the DB is deleted, reload the WebView.
                Log.v(TAG, "clear:onPostExecute");
                Toast.makeText(LogActionsActivity.this, R.string.success_logs_clear, Toast.LENGTH_LONG).show();
                setResult(RESULT_OK);
                finish();
            }
        };
        asyncTask.execute();
    }
}

From source file:org.globalquakemodel.org.idctdo.EQForm_MapView.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (DEBUG_LOG)
        Log.d(TAG, "ON CREATE");
    setContentView(R.layout.map_view);//from   w  ww.  j  a  v  a2 s.  co  m
    mContext = this;

    MyStateSaver data = (MyStateSaver) getLastNonConfigurationInstance();
    if (data != null) {
        // Show splash screen if still loading
        if (data.showSplashScreen) {
            showSplashScreen();
        }
        setContentView(R.layout.map_view);

        // Rebuild your UI with your saved state here
    } else {
        showSplashScreen();
        setContentView(R.layout.map_view);
        // Do your heavy loading here on a background thread

    }

    //showSplashScreen();

    mWebView = (WebView) findViewById(R.id.map_webview);
    mWebView.getSettings().setAllowFileAccess(true);
    mWebView.getSettings().setJavaScriptEnabled(true);

    mWebView.setWebChromeClient(new WebChromeClient() {
        public boolean onConsoleMessage(ConsoleMessage cm) {
            if (DEBUG_LOG)
                Log.d(TAG, cm.message() + " -- From line " + cm.lineNumber() + " of " + cm.sourceId());
            return true;
        }
    });

    if (DEBUG_LOG)
        Log.d(TAG, "adding JS interface");
    mWebView.addJavascriptInterface(this, "webConnector");

    mWebView.loadUrl("file:///android_asset/idct_map.html");
    mWebView.setWebViewClient(new MapWebViewClient());
    progressBar = new ProgressDialog(EQForm_MapView.this);
    progressBar.setMessage("Loading maps...");
    progressBar.setCancelable(false);
    progressBar.setButton(DialogInterface.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });

    //Create Folder
    mediaFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/gemmedia");
    mediaFile.mkdirs();

    //Create Folder
    vectorsFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/kml");
    vectorsFile.mkdirs();

    mapTilesFile = new File(Environment.getExternalStorageDirectory().toString() + "/idctdo/maptiles");
    mapTilesFile.mkdirs();

    File testFile = new File(
            Environment.getExternalStorageDirectory().toString() + "/idctdo/kml/PUT_KML_FILES_HERE");
    try {
        testFile.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    File testFile2 = new File(Environment.getExternalStorageDirectory().toString()
            + "/idctdo/maptiles/PUT_DIRECTORIES_OF_ZYX_TILES_HERE");
    try {
        testFile2.createNewFile();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

    /** Creating a progress dialog window */
    mProgressDialog = new ProgressDialog(this);

    /** Close the dialog window on pressing back button */
    mProgressDialog.setCancelable(true);

    /** Setting a horizontal style progress bar */
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    /** Setting a message for this progress dialog
    * Use the method setTitle(), for setting a title
    * for the dialog window
    *  */
    mProgressDialog.setMessage("Loading map data...");

    vectorsFile.toString();
    new SingleMediaScanner(this, testFile);
    new SingleMediaScanner(this, testFile2);

    sdCardPath = "file:///" + Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
    if (DEBUG_LOG)
        Log.d(TAG, "sdcard Path: " + sdCardPath);
    // Restore preferences
    PreferenceManager.getDefaultSharedPreferences(this);
    //SharedPreferences settings = getSharedPreferences("R.xml.prefs"), 0);

    mlocListener = new MyLocationListener();
    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    currentLocation = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);

    btn_locateMe = (Button) findViewById(R.id.btn_locate_me);
    btn_locateMe.setOnClickListener(locateMeListener);

    btn_takeCameraPhoto = (Button) findViewById(R.id.btn_take_photo);
    btn_takeCameraPhoto.setOnClickListener(takePhotoListener);

    //btn_take_survey_photo=(Button)findViewById(R.id.btn_take_survey_photo);
    //btn_take_survey_photo.setVisibility(View.INVISIBLE);//Poss Dodgy threading stuff using this

    btn_startSurvey = (Button) findViewById(R.id.btn_start_survey);
    btn_startSurvey.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_startSurvey.setOnClickListener(startSurveyListener);

    btn_cancelSurveyPoint = (Button) findViewById(R.id.btn_cancel_survey_point);
    btn_cancelSurveyPoint.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_cancelSurveyPoint.setOnClickListener(cancelSurveyPointListener);

    btn_startSurveyFavourite = (Button) findViewById(R.id.btn_start_survey_with_favourite);
    btn_startSurveyFavourite.setVisibility(View.INVISIBLE);//Dodgy threading stuff using this
    btn_startSurveyFavourite.setOnClickListener(selectFavouriteListener);

    btn_selectLayer = (Button) findViewById(R.id.btn_select_layer);
    btn_selectLayer.setOnClickListener(selectLayerListener);

    btn_selectVectorLayer = (Button) findViewById(R.id.btn_select_vector_layer);
    btn_selectVectorLayer.setOnClickListener(selectVectorLayerListener);

    btn_zoomIn = (Button) findViewById(R.id.btn_zoom_in);
    btn_zoomIn.setOnClickListener(zoomInListener);
    btn_zoomOut = (Button) findViewById(R.id.btn_zoom_out);
    btn_zoomOut.setOnClickListener(zoomOutListener);

    btn_edit_points = (ToggleButton) findViewById(R.id.btn_edit_points);
    btn_edit_points.setOnClickListener(editPointsListener);

    text_view_gpsInfo = (TextView) findViewById(R.id.text_view_gpsInfo);
    text_view_gpsInfo2 = (TextView) findViewById(R.id.text_view_gpsInfo2);

    //Load any of the previous survey points
    loadPrevSurveyPoints();
}