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;

4.4 (5 Votes)
0
4
5
Keyboard-k 100 points

                                    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);
    }
};

4 (5 Votes)
0
3.56
9
Alex Kazan 100 points

                                           
btnPaired.setOnClickListener(new View.OnClickListener() {            @Override            public void onClick(View v)            {                pairedDevicesList(); //method that will be called            }        });

3.56 (9 Votes)
0
0
0
Colinro 80 points

                                    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;

0
0
4.86
7

                                    Button btnPaired;ListView devicelist;

4.86 (7 Votes)
0
0
0
MaryW 85 points

                                    private void msg(String s)   {             Toast.makeText(getApplicationContext(),s,Toast.LENGTH_LONG).show();   }

0
0
3.67
3

                                    private BluetoothAdapter myBluetooth = null;private Set pairedDevices;

3.67 (3 Votes)
0
0
7
Fcpenha 105 points

                                    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}

0
0
3.89
9

                                    private void turnOffLed()
{
    if (btSocket!=null)
    {
        try
        {
            btSocket.getOutputStream().write("TF".toString().getBytes());
        }
        catch (IOException e)
        {
            msg("Error");
        }
    }
}

3.89 (9 Votes)
0
Are there any code examples left?
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source