List of usage examples for android.bluetooth BluetoothAdapter ACTION_REQUEST_ENABLE
String ACTION_REQUEST_ENABLE
To view the source code for android.bluetooth BluetoothAdapter ACTION_REQUEST_ENABLE.
Click Source Link
From source file:com.shenqu.jlplayer.nRFUARTv2.MainActivity.java
@Override public void onResume() { super.onResume(); Log.v(TAG, "onResume"); if (!mBtAdapter.isEnabled()) { Log.i(TAG, "onResume - BT not enabled yet"); Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); }/* w w w. j av a 2 s. c o m*/ }
From source file:cc.mintcoin.wallet.ui.RequestCoinsFragment.java
@Override public View onCreateView(final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) { final View view = inflater.inflate(R.layout.request_coins_fragment, container, false); qrView = (ImageView) view.findViewById(R.id.request_coins_qr); qrView.setOnClickListener(new OnClickListener() { @Override// w ww . java 2 s .c o m public void onClick(final View v) { BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); final CurrencyAmountView btcAmountView = (CurrencyAmountView) view .findViewById(R.id.request_coins_amount_btc); btcAmountView.setCurrencySymbol(config.getBtcPrefix()); btcAmountView.setInputPrecision(config.getBtcMaxPrecision()); btcAmountView.setHintPrecision(config.getBtcPrecision()); btcAmountView.setShift(config.getBtcShift()); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.request_coins_amount_local); localAmountView.setInputPrecision(Constants.LOCAL_PRECISION); localAmountView.setHintPrecision(Constants.LOCAL_PRECISION); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); addressView = (Spinner) view.findViewById(R.id.request_coins_fragment_address); final List<ECKey> keys = new LinkedList<ECKey>(); for (final ECKey key : application.getWallet().getKeys()) if (!wallet.isKeyRotating(key)) keys.add(key); final WalletAddressesAdapter adapter = new WalletAddressesAdapter(activity, wallet, false); adapter.replace(keys); addressView.setAdapter(adapter); final Address selectedAddress = application.determineSelectedAddress(); for (int i = 0; i < keys.size(); i++) { final Address address = keys.get(i).toAddress(Constants.NETWORK_PARAMETERS); if (address.equals(selectedAddress)) { addressView.setSelection(i); break; } } acceptBluetoothPaymentView = (CheckBox) view.findViewById(R.id.request_coins_accept_bluetooth_payment); acceptBluetoothPaymentView .setVisibility(ENABLE_BLUETOOTH_LISTENING && bluetoothAdapter != null ? View.VISIBLE : View.GONE); acceptBluetoothPaymentView .setChecked(ENABLE_BLUETOOTH_LISTENING && bluetoothAdapter != null && bluetoothAdapter.isEnabled()); acceptBluetoothPaymentView.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(final CompoundButton buttonView, final boolean isChecked) { if (ENABLE_BLUETOOTH_LISTENING && bluetoothAdapter != null && isChecked) { if (bluetoothAdapter.isEnabled()) { startBluetoothListening(); } else { // ask for permission to enable bluetooth startActivityForResult(new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_CODE_ENABLE_BLUETOOTH); } } else { stopBluetoothListening(); } updateView(); } }); initiateRequestView = (TextView) view.findViewById(R.id.request_coins_fragment_initiate_request); return view; }
From source file:com.google.sample.beaconservice.MainActivityFragment.java
private void createScanner() { BluetoothManager btManager = (BluetoothManager) getActivity().getSystemService(Context.BLUETOOTH_SERVICE); BluetoothAdapter btAdapter = btManager.getAdapter(); if (btAdapter == null || !btAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, Constants.REQUEST_CODE_ENABLE_BLE); }//from w w w. jav a2s. com if (btAdapter == null || !btAdapter.isEnabled()) { Log.e(TAG, "Can't enable Bluetooth"); Toast.makeText(getActivity(), "Can't enable Bluetooth", Toast.LENGTH_SHORT).show(); return; } scanner = btAdapter.getBluetoothLeScanner(); }
From source file:com.mattprecious.notisync.service.SecondaryService.java
private Notification buildRunningNotification() { NotificationCompat.Builder builder = new NotificationCompat.Builder(this); builder.setPriority(NotificationCompat.PRIORITY_MIN); builder.setSmallIcon(R.drawable.ic_stat_logo); builder.setContentTitle(getString(R.string.app_name)); Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); builder.setContentIntent(pendingIntent); if (!bluetoothAdapter.isEnabled()) { builder.setContentText(getString(R.string.noti_bt_not_enabled)); PendingIntent bluetoothIntent = PendingIntent.getActivity(this, 0, new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), 0); builder.addAction(R.drawable.ic_action_bluetooth, getString(R.string.noti_action_enable_bt), bluetoothIntent);/*from w w w . j av a 2 s. c o m*/ } else if (connectedDeviceName == null) { builder.setContentText(getString(R.string.noti_not_connected)); } else { builder.setContentText(getString(R.string.noti_connected_to, connectedDeviceName)); } return builder.build(); }
From source file:nrec.basil.wimuconsole.SensorSettingsActivity.java
public void connectToImu(View view) { // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); return;/*from w w w . ja v a 2 s. c o m*/ } else { if (mBluetoothService == null) { // Initialize the BluetoothChatService to perform bluetooth connections mBluetoothService = new BluetoothService(this, mHandler); } } // Get the IMU MAC address from our list String address = imuSpinner.getSelectedItem().toString(); // Get the BluetoothDevice object BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(address); // Attempt to connect to the device mBluetoothService.connect(device, false); }
From source file:edu.stanford.mobisocial.dungbeetle.ui.fragments.FeedActionsFragment.java
public void requestBluetooth() { if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) { Intent bt = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(bt, REQUEST_BT_ENABLE); return;//from ww w . j a v a2s. c o m } final int DISCO_LENGTH = 300; Intent discoverableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE); discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, DISCO_LENGTH); startActivityForResult(discoverableIntent, REQUEST_BT_BROADCAST); }
From source file:com.devwang.logcabin.LogCabinMainActivity.java
@SuppressLint("NewApi") @Override/*w w w .ja v a 2 s. c o m*/ public void onStart() {// ActivityOnStart() super.onStart(); if (D) Log.e(TAG, "++ ON START ++"); // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult if (!mBluetoothAdapter.isEnabled()) {// APP Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);// startActivityForResult(enableIntent, REQUEST_ENABLE_BT);// // Otherwise, setup the chat session } else {// if (mChatService == null) setupChat(); } }
From source file:com.wearme.fat.ui.MainActivity.java
@Override protected void onResume() { super.onResume(); if (!mBluetoothAdapter.isEnabled()) { if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); }// w w w. j a v a2 s. c o m } mShakeListener.start(); registerReceiver(mGattUpdateReceiver, makeGattUpdateIntentFilter()); }
From source file:com.imagine.BaseActivity.java
void btTurnOn() { Intent btOn = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(btOn, REQUEST_BT_ON); }
From source file:org.surfsite.iconsole.BluetoothChatFragment.java
@Override public void onStart() { super.onStart(); // If BT is not on, request that it be enabled. // setupChat() will then be called during onActivityResult if (null == mBluetoothAdapter || !mBluetoothAdapter.isEnabled()) { Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntent, REQUEST_ENABLE_BT); // Otherwise, setup the chat session } else if (mChatService == null) { setupChat();//from w w w. j a v a2 s . c om } if (!mChannelServiceBound) doBindChannelService(); }