arduino ble led dimmer code
myBluetooth = BluetoothAdapter.getDefaultAdapter();if(myBluetooth == null) { //Show a mensag. that thedevice has no bluetooth adapter Toast.makeText(getApplicationContext(), "Bluetooth Device Not Available", Toast.LENGTH_LONG).show(); //finish apk finish(); }
else { if (myBluetooth.isEnabled()) { } else {
//Ask to the user turn the bluetooth on
Intent turnBTon = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(turnBTon,1); }}
4.4
5
import android.widget.Button;
import android.widget.ListView;
Thank you!
5
0
4
5
private AdapterView.OnItemClickListener myListClickListener = new AdapterView.OnItemClickListener()
{
public void onItemClick (AdapterView av, View v, int arg2, long arg3)
{
// Get the device MAC address, the last 17 chars in the View
String info = ((TextView) v).getText().toString();
String address = info.substring(info.length() - 17);
// Make an intent to start next activity.
Intent i = new Intent(DeviceList.this, ledControl.class);
//Change the activity.
i.putExtra(EXTRA_ADDRESS, address); //this will be received at ledControl (class) Activity
startActivity(i);
}
};
Thank you!
5
0
3.56
9
btnPaired.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { pairedDevicesList(); //method that will be called } });
Thank you!
9
0
0
0
import android.bluetooth.BluetoothSocket;
import android.content.Intent;import android.view.View;import android.widget.Button;import android.widget.SeekBar;import android.widget.TextView;import android.widget.Toast;import android.app.ProgressDialog;import android.bluetooth.BluetoothAdapter;import android.bluetooth.BluetoothDevice;import android.os.AsyncTask;import java.io.IOException;import java.util.UUID;
Thank you!
0
0
4.86
7
Button btnPaired;ListView devicelist;
Thank you!
7
0
0
0
private void msg(String s) { Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show(); }
Thank you!
0
0
3.67
3
private BluetoothAdapter myBluetooth = null;private Set pairedDevices;
Thank you!
3
0
0
7
private void Disconnect(){
if (btSocket!=null) //If the btSocket is busy
{
try
{
btSocket.close(); //close connection
}
catch (IOException e)
{ msg("Error");}
}
finish(); //return to the first layout}
Thank you!
7
0
3.89
9
private void turnOffLed()
{
if (btSocket!=null)
{
try
{
btSocket.getOutputStream().write("TF".toString().getBytes());
}
catch (IOException e)
{
msg("Error");
}
}
}
Thank you!
9
0
Are there any code examples left?
New code examples in category Other
-
Other 2023-03-27 22:50:10 how to select the whole line in vscode with keyboard shortcut
-
Other 2022-03-27 22:45:24 income of a web developer
-
Other 2022-03-27 22:35:01 \pyrcc_main.py: File does not exist 'resources.qrc'
-
Other 2022-03-27 22:30:45 rick roll embed code
-
Other 2022-03-27 22:20:08 Circuit_04_Potentiometer
-
Other 2022-03-27 22:20:05 iterative power
-
Other 2022-03-27 22:15:11 flutter run all
-
Other 2022-03-27 22:10:05 when is karlson release
-
Other 2022-03-27 22:10:02 wp .htaccess example
-
Other 2022-03-27 22:00:08 bash pause in file read line by line