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.woollysammoth.nubit_android_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 . ja v a 2s . co m public void onClick(final View v) { BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); final CurrencyAmountView NBTAmountView = (CurrencyAmountView) view .findViewById(R.id.request_coins_amount_ppc); NBTAmountView.setCurrencySymbol(config.getNBTPrefix()); NBTAmountView.setInputPrecision(config.getNBTMaxPrecision()); NBTAmountView.setHintPrecision(config.getNBTPrecision()); NBTAmountView.setShift(config.getNBTShift()); 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(NBTAmountView, localAmountView); 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.cannabiscoin.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//from www. ja v a 2 s . com 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); 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.matthewmitchell.nubits_android_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 .j a v a 2s .c o m*/ public void onClick(final View v) { BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); final CurrencyAmountView NBTAmountView = (CurrencyAmountView) view .findViewById(R.id.request_coins_amount_nbt); NBTAmountView.setCurrencySymbol(config.getNBTPrefix()); NBTAmountView.setInputPrecision(config.getNBTMaxPrecision()); NBTAmountView.setHintPrecision(config.getNBTPrecision()); NBTAmountView.setShift(config.getNBTShift()); 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(NBTAmountView, localAmountView); 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.matthewmitchell.peercoin_android_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//www. j a va2 s . com public void onClick(final View v) { BitmapFragment.show(getFragmentManager(), qrCodeBitmap); } }); final CurrencyAmountView PPCAmountView = (CurrencyAmountView) view .findViewById(R.id.request_coins_amount_ppc); PPCAmountView.setCurrencySymbol(config.getPPCPrefix()); PPCAmountView.setInputPrecision(config.getPPCMaxPrecision()); PPCAmountView.setHintPrecision(config.getPPCPrecision()); PPCAmountView.setShift(config.getPPCShift()); 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(PPCAmountView, localAmountView); 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:io.github.msc42.masterthemaze.GameActivity.java
private void enableBluetoothAndStartGame() { if (mBluetoothAdapter.isEnabled()) { requestReadExternalStoragePermissionAndStartGame(); } else {/* ww w .ja va2s. c om*/ Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, Constants.REQUEST_ENABLE_BT); // if request is satisfied, in onActivityResult requestReadExternalStoragePermissionAndStartGame // is called, otherwise there is an alert dialog, which finishes the app when it is confirmed } }
From source file:org.bart452.runningshoesensor.MainActivity.java
private void bleEnable() { if (!mBleAdapter.isEnabled()) { mSnackBar = Snackbar.make((CoordinatorLayout) findViewById(R.id.coordinator), "Please enable Bluetooth", Snackbar.LENGTH_INDEFINITE); mSnackBar.setAction("Enable", new View.OnClickListener() { @Override/*from w ww. j av a 2 s.c om*/ public void onClick(View v) { Intent i = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivity(i); mScanFab.setEnabled(true); } }); mSnackBar.show(); } }
From source file:top.isense.demo.testsensor.DeviceScanActivity.java
@Override protected void onResume() { super.onResume(); // Ensures Bluetooth is enabled on the device. If Bluetooth is not currently enabled, // fire an intent to display a dialog asking the user to grant permission to enable it. if (!mBluetoothAdapter.isEnabled()) { if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); }/* w w w.java2 s . c o m*/ } // Initializes list view adapter. mLeDeviceListAdapter = new LeDeviceListAdapter(); //Because of changing the extend from ListActivity to AppComActivity, //in corresponding, change the setListAdapter to setAdapter mListView.setAdapter(mLeDeviceListAdapter); scanLeDevice(true); }
From source file:com.molidt.easyandroid.bluetooth.BluetoothFragmentV4.java
/** * If you want to get the callback result, please use * {@link #setBluetoothStateListener(BluetoothFragmentV4.BluetoothStateListener)} before * or usd {@link #setBluetoothEnable(BluetoothFragmentV4.BluetoothStateListener)} directly *///from www . j av a 2 s . co m public void setBluetoothEnable() { if (isSupportBluetooth) { if (!mBluetoothAdapter.isEnabled()) { Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT); } } }
From source file:org.hopestarter.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); final CardView qrCardView = (CardView) view.findViewById(R.id.request_coins_qr_card); qrCardView.setCardBackgroundColor(Color.WHITE); qrCardView.setPreventCornerOverlap(false); qrCardView.setOnClickListener(new OnClickListener() { @Override/*from ww w . j a v a2 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.getFormat().code()); btcAmountView.setInputFormat(config.getMaxPrecisionFormat()); btcAmountView.setHintFormat(config.getFormat()); final CurrencyAmountView localAmountView = (CurrencyAmountView) view .findViewById(R.id.request_coins_amount_local); localAmountView.setInputFormat(Constants.LOCAL_FORMAT); localAmountView.setHintFormat(Constants.LOCAL_FORMAT); amountCalculatorLink = new CurrencyCalculatorLink(btcAmountView, localAmountView); 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.example.mego.adas.main.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //Get the MAC address from the Connect Device Activity Intent newIntent = getIntent();//ww w. j a v a 2s . co m if (savedInstanceState == null) { address = newIntent.getStringExtra(ConnectFragment.EXTRA_DEVICE_ADDRESS); } else { address = savedInstanceState.getString(address_key); } setContentView(R.layout.activity_main); //Initialize the Firebase auth object mFirebaseAuth = FirebaseAuth.getInstance(); //Set up the firebase mFirebaseDatabase = FirebaseDatabase.getInstance(); //Get the current device token deviceToken = FirebaseInstanceId.getInstance().getToken(); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); backgroundImageView = findViewById(R.id.start_program_imageView); DrawerLayout drawer = findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); View headerView = navigationView.inflateHeaderView(R.layout.nav_header_main); initializeScreen(headerView); //display current user image Bitmap userImageBitmap = AdasUtils .loadUserImageFromStorage(AdasUtils.getCurrentUserImagePath(MainActivity.this)); if (userImageBitmap != null) { userImageView.setImageBitmap(userImageBitmap); } else { userImageView.setImageResource(R.drawable.car_profile_icon); } openEditAccountActivity(); //check if the device has a bluetooth or not //and show Toast message if it does't have mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); if (mBluetoothAdapter == null) { if (toast != null) { toast.cancel(); } toast = Toast.makeText(this, R.string.does_not_have_bluetooth, Toast.LENGTH_SHORT); toast.show(); } else if (!mBluetoothAdapter.isEnabled()) { Intent enableIntentBluetooth = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); startActivityForResult(enableIntentBluetooth, REQUEST_ENABLE_BT); } newConnectionFlag++; if (NetworkUtil.isAvailableInternetConnection(this)) { if (mFirebaseAuth.getCurrentUser().getUid() != null) { isPhoneAuthDatabaseReference = mFirebaseDatabase.getReference().child(FIREBASE_USERS) .child(mFirebaseAuth.getCurrentUser().getUid()).child(Constants.FIREBASE_IS_VERIFIED_PHONE); getPhoneVerificationState(); } } else { showToast(getString(R.string.no_internet_connection)); } displayUserData(); verifyUserData(); AdasSyncUtils.scheduleAdvices(this); }