Example usage for android.provider Settings ACTION_BLUETOOTH_SETTINGS

List of usage examples for android.provider Settings ACTION_BLUETOOTH_SETTINGS

Introduction

In this page you can find the example usage for android.provider Settings ACTION_BLUETOOTH_SETTINGS.

Prototype

String ACTION_BLUETOOTH_SETTINGS

To view the source code for android.provider Settings ACTION_BLUETOOTH_SETTINGS.

Click Source Link

Document

Activity Action: Show settings to allow configuration of Bluetooth.

Usage

From source file:Main.java

/**
 * Show dialog and give 2 options: go to settings or leave the app
 *
 * @param activity the activity/* w w  w.  j av a  2s.c  o m*/
 */
private static void showDialog(final Activity activity) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);

    builder.setTitle("Bluetooth is turned off");
    builder.setMessage("The Tapcentive Application requires Bluetooth to be turned ON");
    builder.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent setnfc = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
            activity.startActivity(setnfc);
        }
    });
    builder.setNegativeButton("Close", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.cancel();
            activity.finish();
        }
    });
    builder.show();
}

From source file:org.deviceconnect.android.deviceplugin.fplug.setting.fragment.FPLUGPairingFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.pairing_fplug, container, false);
    root.findViewById(R.id.bluetooth).setOnClickListener(new View.OnClickListener() {
        @Override/*from   w w w .j  a  va2 s.  c om*/
        public void onClick(View v) {
            startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
        }
    });
    return root;
}

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

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {
    View root = inflater.inflate(R.layout.setting_pairing, null);

    final ImageView image = (ImageView) root.findViewById(R.id.animView);
    image.setBackgroundResource(R.drawable.sphero_light);

    Button button = (Button) root.findViewById(R.id.btnSetting);
    button.setOnClickListener(new OnClickListener() {
        @Override/*  w w w  .  ja va2 s . c  o  m*/
        public void onClick(final View v) {
            startActivity(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS));
        }
    });
    View permission = root.findViewById(R.id.ble_permission);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        permission.setVisibility(View.GONE);
    } else {
        permission.setVisibility(View.VISIBLE);
    }

    mBlePermissionBtn = (Button) root.findViewById(R.id.button_permission);
    mBlePermissionBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (BleUtils.isBLEPermission(getActivity())) {
                openAndroidSettings();
            } else {
                requestPermissions();
            }
        }
    });
    return root;
}

From source file:com.phonegap.plugins.nativesettings.NativeSettings.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
    PluginResult.Status status = PluginResult.Status.OK;
    Uri packageUri = Uri.parse("package:" + this.cordova.getActivity().getPackageName());
    String result = "";

    //Information on settings can be found here:
    //http://developer.android.com/reference/android/provider/Settings.html

    action = args.getString(0);//from www .j  a va2  s .  c o m
    Intent intent = null;

    if (action.equals("accessibility")) {
        intent = new Intent(android.provider.Settings.ACTION_ACCESSIBILITY_SETTINGS);
    } else if (action.equals("account")) {
        intent = new Intent(android.provider.Settings.ACTION_ADD_ACCOUNT);
    } else if (action.equals("airplane_mode")) {
        intent = new Intent(android.provider.Settings.ACTION_AIRPLANE_MODE_SETTINGS);
    } else if (action.equals("apn")) {
        intent = new Intent(android.provider.Settings.ACTION_APN_SETTINGS);
    } else if (action.equals("application_details")) {
        intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS, packageUri);
    } else if (action.equals("application_development")) {
        intent = new Intent(android.provider.Settings.ACTION_APPLICATION_DEVELOPMENT_SETTINGS);
    } else if (action.equals("application")) {
        intent = new Intent(android.provider.Settings.ACTION_APPLICATION_SETTINGS);
    }
    //else if (action.equals("battery_saver")) {
    //    intent = new Intent(android.provider.Settings.ACTION_BATTERY_SAVER_SETTINGS);
    //}
    else if (action.equals("bluetooth")) {
        intent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
    } else if (action.equals("captioning")) {
        intent = new Intent(android.provider.Settings.ACTION_CAPTIONING_SETTINGS);
    } else if (action.equals("cast")) {
        intent = new Intent(android.provider.Settings.ACTION_CAST_SETTINGS);
    } else if (action.equals("data_roaming")) {
        intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS);
    } else if (action.equals("date")) {
        intent = new Intent(android.provider.Settings.ACTION_DATE_SETTINGS);
    } else if (action.equals("about")) {
        intent = new Intent(android.provider.Settings.ACTION_DEVICE_INFO_SETTINGS);
    } else if (action.equals("display")) {
        intent = new Intent(android.provider.Settings.ACTION_DISPLAY_SETTINGS);
    } else if (action.equals("dream")) {
        intent = new Intent(android.provider.Settings.ACTION_DREAM_SETTINGS);
    } else if (action.equals("home")) {
        intent = new Intent(android.provider.Settings.ACTION_HOME_SETTINGS);
    } else if (action.equals("keyboard")) {
        intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SETTINGS);
    } else if (action.equals("keyboard_subtype")) {
        intent = new Intent(android.provider.Settings.ACTION_INPUT_METHOD_SUBTYPE_SETTINGS);
    } else if (action.equals("storage")) {
        intent = new Intent(android.provider.Settings.ACTION_INTERNAL_STORAGE_SETTINGS);
    } else if (action.equals("locale")) {
        intent = new Intent(android.provider.Settings.ACTION_LOCALE_SETTINGS);
    } else if (action.equals("location")) {
        intent = new Intent(android.provider.Settings.ACTION_LOCATION_SOURCE_SETTINGS);
    } else if (action.equals("manage_all_applications")) {
        intent = new Intent(android.provider.Settings.ACTION_MANAGE_ALL_APPLICATIONS_SETTINGS);
    } else if (action.equals("manage_applications")) {
        intent = new Intent(android.provider.Settings.ACTION_MANAGE_APPLICATIONS_SETTINGS);
    } else if (action.equals("memory_card")) {
        intent = new Intent(android.provider.Settings.ACTION_MEMORY_CARD_SETTINGS);
    } else if (action.equals("network")) {
        intent = new Intent(android.provider.Settings.ACTION_NETWORK_OPERATOR_SETTINGS);
    } else if (action.equals("nfcsharing")) {
        intent = new Intent(android.provider.Settings.ACTION_NFCSHARING_SETTINGS);
    } else if (action.equals("nfc_payment")) {
        intent = new Intent(android.provider.Settings.ACTION_NFC_PAYMENT_SETTINGS);
    } else if (action.equals("nfc_settings")) {
        intent = new Intent(android.provider.Settings.ACTION_NFC_SETTINGS);
    }
    //else if (action.equals("notification_listner")) {
    //    intent = new Intent(android.provider.Settings.ACTION_NOTIFICATION_LISTENER_SETTINGS);
    //}
    else if (action.equals("print")) {
        intent = new Intent(android.provider.Settings.ACTION_PRINT_SETTINGS);
    } else if (action.equals("privacy")) {
        intent = new Intent(android.provider.Settings.ACTION_PRIVACY_SETTINGS);
    } else if (action.equals("quick_launch")) {
        intent = new Intent(android.provider.Settings.ACTION_QUICK_LAUNCH_SETTINGS);
    } else if (action.equals("search")) {
        intent = new Intent(android.provider.Settings.ACTION_SEARCH_SETTINGS);
    } else if (action.equals("security")) {
        intent = new Intent(android.provider.Settings.ACTION_SECURITY_SETTINGS);
    } else if (action.equals("settings")) {
        intent = new Intent(android.provider.Settings.ACTION_SETTINGS);
    } else if (action.equals("show_regulatory_info")) {
        intent = new Intent(android.provider.Settings.ACTION_SHOW_REGULATORY_INFO);
    } else if (action.equals("sound")) {
        intent = new Intent(android.provider.Settings.ACTION_SOUND_SETTINGS);
    } else if (action.equals("store")) {
        intent = new Intent(Intent.ACTION_VIEW,
                Uri.parse("market://details?id=" + this.cordova.getActivity().getPackageName()));
    } else if (action.equals("sync")) {
        intent = new Intent(android.provider.Settings.ACTION_SYNC_SETTINGS);
    } else if (action.equals("usage")) {
        intent = new Intent(android.provider.Settings.ACTION_USAGE_ACCESS_SETTINGS);
    } else if (action.equals("user_dictionary")) {
        intent = new Intent(android.provider.Settings.ACTION_USER_DICTIONARY_SETTINGS);
    } else if (action.equals("voice_input")) {
        intent = new Intent(android.provider.Settings.ACTION_VOICE_INPUT_SETTINGS);
    } else if (action.equals("wifi_ip")) {
        intent = new Intent(android.provider.Settings.ACTION_WIFI_IP_SETTINGS);
    } else if (action.equals("wifi")) {
        intent = new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS);
    } else if (action.equals("wireless")) {
        intent = new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS);
    } else {
        status = PluginResult.Status.INVALID_ACTION;
        callbackContext.sendPluginResult(new PluginResult(status, result));
        return false;
    }

    if (args.length() > 1 && args.getBoolean(1)) {
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    }
    this.cordova.getActivity().startActivity(intent);

    callbackContext.sendPluginResult(new PluginResult(status, result));
    return true;
}

From source file:org.deviceconnect.android.deviceplugin.heartrate.fragment.BluetoothSettingsFragment.java

private void openBluetoothSettings() {
    Intent intent = new Intent();
    intent.setAction(Settings.ACTION_BLUETOOTH_SETTINGS);
    startActivity(intent);
}

From source file:com.megster.cordova.ble.central.BLECentralPlugin.java

@Override
public boolean execute(String action, CordovaArgs args, CallbackContext callbackContext) throws JSONException {

    LOG.d(TAG, "action = " + action);

    if (bluetoothAdapter == null) {
        Activity activity = cordova.getActivity();
        BluetoothManager bluetoothManager = (BluetoothManager) activity
                .getSystemService(Context.BLUETOOTH_SERVICE);
        bluetoothAdapter = bluetoothManager.getAdapter();
    }/*from  ww  w.  j a v  a2 s  .c om*/

    boolean validAction = true;

    if (action.equals(SCAN)) {

        UUID[] serviceUUIDs = parseServiceUUIDList(args.getJSONArray(0));
        int scanSeconds = args.getInt(1);
        findLowEnergyDevices(callbackContext, serviceUUIDs, scanSeconds);

    } else if (action.equals(START_SCAN)) {

        UUID[] serviceUUIDs = parseServiceUUIDList(args.getJSONArray(0));
        findLowEnergyDevices(callbackContext, serviceUUIDs, -1);

    } else if (action.equals(STOP_SCAN)) {

        bluetoothAdapter.stopLeScan(this);
        callbackContext.success();

    } else if (action.equals(LIST)) {

        listKnownDevices(callbackContext);

    } else if (action.equals(CONNECT)) {

        String macAddress = args.getString(0);
        connect(callbackContext, macAddress);

    } else if (action.equals(DISCONNECT)) {

        String macAddress = args.getString(0);
        disconnect(callbackContext, macAddress);

    } else if (action.equals(READ)) {

        String macAddress = args.getString(0);
        UUID serviceUUID = uuidFromString(args.getString(1));
        UUID characteristicUUID = uuidFromString(args.getString(2));
        read(callbackContext, macAddress, serviceUUID, characteristicUUID);

    } else if (action.equals(WRITE)) {

        String macAddress = args.getString(0);
        UUID serviceUUID = uuidFromString(args.getString(1));
        UUID characteristicUUID = uuidFromString(args.getString(2));
        byte[] data = args.getArrayBuffer(3);
        int type = BluetoothGattCharacteristic.WRITE_TYPE_DEFAULT;
        write(callbackContext, macAddress, serviceUUID, characteristicUUID, data, type);

    } else if (action.equals(WRITE_WITHOUT_RESPONSE)) {

        String macAddress = args.getString(0);
        UUID serviceUUID = uuidFromString(args.getString(1));
        UUID characteristicUUID = uuidFromString(args.getString(2));
        byte[] data = args.getArrayBuffer(3);
        int type = BluetoothGattCharacteristic.WRITE_TYPE_NO_RESPONSE;
        write(callbackContext, macAddress, serviceUUID, characteristicUUID, data, type);

    } else if (action.equals(START_NOTIFICATION)) {

        String macAddress = args.getString(0);
        UUID serviceUUID = uuidFromString(args.getString(1));
        UUID characteristicUUID = uuidFromString(args.getString(2));
        registerNotifyCallback(callbackContext, macAddress, serviceUUID, characteristicUUID);

    } else if (action.equals(STOP_NOTIFICATION)) {

        String macAddress = args.getString(0);
        UUID serviceUUID = uuidFromString(args.getString(1));
        UUID characteristicUUID = uuidFromString(args.getString(2));
        removeNotifyCallback(callbackContext, macAddress, serviceUUID, characteristicUUID);

    } else if (action.equals(IS_ENABLED)) {

        if (bluetoothAdapter.isEnabled()) {
            callbackContext.success();
        } else {
            callbackContext.error("Bluetooth is disabled.");
        }

    } else if (action.equals(IS_CONNECTED)) {

        String macAddress = args.getString(0);

        if (peripherals.containsKey(macAddress) && peripherals.get(macAddress).isConnected()) {
            callbackContext.success();
        } else {
            callbackContext.error("Not connected.");
        }

    } else if (action.equals(SETTINGS)) {

        Intent intent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
        cordova.getActivity().startActivity(intent);
        callbackContext.success();

    } else if (action.equals(ENABLE)) {

        enableBluetoothCallback = callbackContext;
        Intent intent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        cordova.startActivityForResult(this, intent, REQUEST_ENABLE_BLUETOOTH);

    } else {

        validAction = false;

    }

    return validAction;
}

From source file:org.bcsphere.activity.BCPage.java

@Override
public void onClick(View v) {
    switch (v.getId()) {
    case R.id.btnManager:
        mActivity.managerPopupWindow.showAsDropDown(view, 0, 0);
        TranslateAnimation animation = new TranslateAnimation(0, 0, 0,
                (float) (getScreenHeight(mActivity) * (430.0 / 1920.0)));
        animation.setDuration(200);/* w  w  w  .  ja va  2  s  .  c  o  m*/
        animation.setFillAfter(true);
        parentView.startAnimation(animation);
        break;

    case R.id.btnMenu:
        if (menuPopupWindow == null) {
            menuPopupWindow = new MenuPopupWindow(mActivity);
        }
        if (menuPopupWindow.isShowing()) {
            menuPopupWindow.dismiss();
            return;
        }
        menuPopupWindow.showAsDropDown(btnMenu, 0, 20);
        break;
    case R.id.btnBack:
        mWebView.goBack();
        break;
    case R.id.btnClose:
        Intent intent = new Intent();
        intent.setAction("removeApp");
        intent.putExtra("removeAppURL", PageManager.getCurrentPager().url);
        mActivity.sendBroadcast(intent);
        PageManager.setDeleteUrl(PageManager.getCurrentPager().url);
        break;
    case R.id.hintOpenBluetooth:
        startActivity(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS));
        break;
    case R.id.hintOpenNetwork:
        startActivity(new Intent(Settings.ACTION_SETTINGS));
        break;
    }
}

From source file:cordova.plugins.Diagnostic.java

public void switchToBluetoothSettings() {
    Log.d(TAG, "Switch to Bluetooth Settings");
    Intent settingsIntent = new Intent(Settings.ACTION_BLUETOOTH_SETTINGS);
    cordova.getActivity().startActivity(settingsIntent);
}

From source file:com.plusot.senselib.SenseMain.java

@SuppressWarnings("deprecation")
public void onPopupResult(int dialogId, int viewId, int iWhich, int itemsSize, String sWhich, String sTag) { // , int tag) {
    switch (dialogId) {
    case VALUE_POPUP:
        switch (iWhich) {
        /*case 0://from  w  w  w . jav  a2s . c  om
           showPopupDialog(VALUESELECT_POPUP, viewId, null); // , 0);
           break;*/
        case 0:
            showMultiChoiceDialog(VALUESELECT_POPUP, viewId);
            break;
        case 1:
            //            if (SenseGlobals.isLite) 
            //               showLiteWarning();
            //            else 
            if (PreferenceKey.VOICEON.isTrue())
                showMultiChoiceDialog(SPEECHSELECT_POPUP, viewId);
            else
                warnNoSpeech();
            break;
        case 2:
            if (popupValue == null) {
                popupValue = viewGetCurrentValue(viewId);
            }
            if (popupValue != null) {
                final String[] units = Unit.getValidUnits(popupValue.getValueType().getUnitType(), this);
                showPopupDialog(UNIT_POPUP, viewId, units);
            }
            break;
        case 3:
            if (sWhich.equals(getString(R.string.calibrate))) {
                calibrate();
            } else if (sWhich.equals(getString(R.string.set_level))) {
                if (Manager.managers.get(ManagerType.SENSOR_MANAGER) == null)
                    return;
                ((AndroidSensorManager) Manager.managers.get(ManagerType.SENSOR_MANAGER)).setLevel();
                ToastHelper.showToastLong(R.string.level_message);
            }
            break;
        }
        break;
    case UNIT_POPUP:
        final Unit unit = Unit.getUnitByChoiceString(sWhich, this);
        if (popupValue != null) {
            popupValue.setUnit(unit);
        }
        break;
    case VALUESELECT_POPUP:
        viewSetValue(viewId, Value.getValueByString(this, sWhich));
        ToastHelper.showToastShort(getString(R.string.hint_long_click));
        saveConfiguration();
        break;
    case YEAR_POPUP:
        logYear = sWhich;
        showPopupDialog(MONTH_POPUP, viewId, null); // , 0);
        break;
    case MONTH_POPUP:
        logMonth = logMonths[iWhich];
        LLog.d(Globals.TAG, CLASSTAG + ".showPopupDialog: logMonth = " + logMonth);
        showPopupDialog(DAY_POPUP, viewId, null); // , 0);
        break;
    case DAY_POPUP:
        logDay = logDays[iWhich];

        if (fileExplorer != null) {
            switch (fileExplorer.getTag()) {
            case FileExplorer.ACTIVITY_TAG:
                showPopupDialog(TIMES_POPUP, viewId, null);
                break;
            }
        }
        break;
    case TIMES_POPUP:
        if (fileExplorer != null) {
            switch (fileExplorer.getTag()) {
            case FileExplorer.ACTIVITY_TAG:
                stopActivity("onPopupResult", false);
                ToastHelper.showToastLong(getString(R.string.chosen_file) + " = " + logDay + " "
                        + DateUtils.getMonthString(logMonth - 1, DateUtils.LENGTH_LONG) + " " + logYear + " "
                        + sWhich);

                DataLog dataLog = DataLog.getInstance();
                if (dataLog != null) {
                    String file = fileExplorer.getFileList(logYear, logMonth, logDay, sWhich);
                    if (file != null) {
                        SenseGlobals.replaySession = logYear + String.format("%02d%02d", logMonth, logDay) + "-"
                                + sWhich.substring(0, 2) + sWhich.substring(3, 5) + sWhich.substring(6, 8);
                        LLog.d(Globals.TAG,
                                CLASSTAG + ".onPopupResult: ReplaySession = " + SenseGlobals.replaySession);
                        dataLog.readCsv(new String[] { file }, this);
                    }
                }
                //               if (showMap) showLocation();
                break;
            }
        }
        break;
    case STEP_POPUP:
        switch (step) {
        case 0:
            argosRecovery = 6 + iWhich;
            step = 1;
            showPopupDialog(STEP_POPUP, VIEW_ID_BASE + viewsAdded - 1, null);
            break;
        case 1:
            LLog.d(Globals.TAG, CLASSTAG + ".onPopuResult: STEP1SETTINGS_POPUP = " + iWhich);
            //ActivityUtil.lockScreenOrientation(this);
            switch (iWhich) {
            case 0:
                startActivityForResult(new Intent(this, BikeSettingsActivity.class), RESULT_STEP1);
                break;
            case 1:
                startActivityForResult(new Intent(SenseMain.this, AntSettingsActivity.class), RESULT_STEP1);
                break;
            case 2:
                startActivityForResult(new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS),
                        RESULT_STEP1);
                break;
            default:
                //enableAnt();
                step = 2;
                showPopupDialog(STEP_POPUP, VIEW_ID_BASE + viewsAdded - 1, null);
                break;
            }
            break;
        case 2:
            if (iWhich == startOptions - 1)
                startUpDialogs("STEP2START_POPUP");
            else {
                View view = this.findViewById(R.id.main_layout);
                if (view != null)
                    view.setVisibility(View.VISIBLE);

                if (iWhich >= 0 && iWhich <= startOptions - 3)
                    startActivity(iWhich == startOptions - 3);
                stepsDone = true;
            }
            lastAskForActivityStart = System.currentTimeMillis();
            break;
        }
        break;
    case MOVESTART_POPUP:
        moveStartBusy = false;
        lastAskForActivityStart = System.currentTimeMillis();
    case START_POPUP:
        if (iWhich >= 0 && iWhich <= itemsSize - 2)
            startActivity(iWhich == itemsSize - 2);

        break;
    case ARGOSSTOP_POPUP:
        switch (argosStopStep) {
        case 0:
            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE).log("recovery=" + argosRecovery);
            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE).log("intensity=" + (6 + iWhich));
            argosStopStep = 1;
            showPopupDialog(ARGOSSTOP_POPUP, VIEW_ID_BASE + viewsAdded - 1, null);

            break;
        case 1:
            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE).log("fitness=" + (6 + iWhich));
            new InputDialog(this, 666, R.string.remarkspopup_title, R.string.remarkspopup_description, "",
                    R.string.remarkspopup_hint, new InputDialog.Listener() {

                        @Override
                        public void onClose(int id, String temp) {
                            SimpleLog.getInstance(SimpleLogType.TEXT, ARGOS_MENTALSTATEFILE)
                                    .log("remark=" + temp);
                            argosStopStep = 2;
                            new SleepAndWake(new SleepAndWake.Listener() {
                                @Override
                                public void onWake() {
                                    shouldFinish = (shouldFinish == 1) ? 2 : 0;
                                    sendMail(true);
                                }
                            }, 100);
                        }
                    }).show();
            break;
        }
        break;

    case FULLSTOP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();

        if (iWhich == 0) {
            ToastHelper.showToastLong(R.string.toast_pause);
            pauseActivity("onPopupResult");
            finishIt();
        } else {
            stopActivity("onPopupResult", true);
        }
        //         if (dialogId == FULLSTOP_POPUP) finishIt();

        break;
    case STOP_POPUP:
        lastAskForActivityStart = System.currentTimeMillis();
        if (iWhich == 0) {
            ToastHelper.showToastLong(R.string.toast_pause);
            pauseActivity("onPopupResult");
        } else {
            stopActivity("onPopupResult", false);
        }
        break;
    case SHARE_POPUP:
        switch (iWhich) {
        case 0:
            this.sendMail(false);
            break;
        case 1:
            //            if (SenseGlobals.isLite) {
            //               this.showLiteWarning();
            //            } else 
            if (!PreferenceKey.HTTPPOST.isTrue())
                showTweetWarning();
            else {
                String link = getString(R.string.tweet_msg, Globals.TAG,
                        PreferenceKey.SHARE_URL.getString() + "?device=" + SenseUserInfo.getDeviceId(),
                        TimeUtil.formatTime(System.currentTimeMillis(), "EEE dd MMM HH:mm:ss"));
                int session = HttpSender.getSession();
                if (session >= 0)
                    link += "&session=" + session;
                new Tweet(this, null).send(link);
            }
            break;
        case 2:
            //            if (SenseGlobals.isLite)
            //               this.showLiteWarning();
            //            else
            this.sendTP();
            break;
        case 3:
            if (!Value.fileTypes.contains(FileType.FIT)) {
                this.warnNoFit();
                break;
            }
            switch (new SendStravaMail(this).send()) {
            case SUCCES:
                break;
            case NOACCOUNT:
                this.warnAccount();
                break;
            case NOFILES:
                this.warnNoFilesToday();
                break;
            }
            break;
        case 4:
            StringBuffer buf = new StringBuffer();
            buf.append("\nApp version: " + UserInfo.appNameVersion() + "\n");
            buf.append("Android version: " + Build.VERSION.RELEASE + "\n");
            buf.append("Android incremental: " + Build.VERSION.INCREMENTAL + "\n");
            buf.append("Android SDK: " + Build.VERSION.SDK_INT + "\n");
            //buf.append("FINGERPRINT: "+Build.FINGERPRINT+ "\n");
            buf.append("Device manufacturer: " + Build.MANUFACTURER + "\n");
            buf.append("Device brand: " + Build.BRAND + "\n");
            buf.append("Device model: " + Build.MODEL + "\n");
            buf.append("Device board: " + Build.BOARD + "\n");
            buf.append("Device id: " + Build.DEVICE);

            new LogMail(this,
                    getString(R.string.reportmail, TimeUtil.formatTime(System.currentTimeMillis()), buf),
                    getString(R.string.mail_sending), getString(R.string.no_mail_to_send), null);
        }
        break;
    case INTERVAL_POPUP:
        switch (iWhich) {
        case 0:
            newInterval();
            break;
        case 1:
            new LapsDialog(this, Laps.getLaps() - 1, false).show();
        }
        break;
    case GPX_POPUP:
        ToastHelper.showToastLong(getString(R.string.get_gpx_file, sWhich + " " + sTag));
        getGPX(sTag);
        break;
    }

}

From source file:com.plusot.senselib.SenseMain.java

private void checkBluetooth() {
    BluetoothAdapter adapter = BluetoothAdapter.getDefaultAdapter();
    if (adapter != null && adapter.getState() != BluetoothAdapter.STATE_OFF) {
        startActivity(true);/*from w  w  w .ja  va 2s  .  c  o  m*/
        return;
    }
    new AlertDialog.Builder(SenseMain.this).setTitle(R.string.warn_nobluetooth_title)
            .setMessage(R.string.warn_nobluetooth_msg)
            .setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    if (dialog != null)
                        dialog.dismiss();
                    startActivityForResult(new Intent(Settings.ACTION_BLUETOOTH_SETTINGS), RESULT_BLUETOOTH);
                }
            }).setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int whichButton) {
                    if (dialog != null)
                        dialog.dismiss();
                    startActivity(true);
                }
            }).setOnCancelListener(new OnCancelListener() {

                @Override
                public void onCancel(DialogInterface dialog) {
                    startActivity(true);
                }
            }).create().show();
}