UUID cannot be resolved error

Here again....

I´m trying to create a Bluetooth connection, I already have the MAC address of the device but when I use createInsecureRfcommSocketToServiceRecord it gives me an error on the UUID... does anyone haves a clue on why is this?.... I appreciate in advance the help.

Here's the Main:

package com.example.mustangsound;



//import java.util.UUID;
import java.util.Set;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothSocket;
import android.content.IntentFilter;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Toast;


public class MainActivity extends Activity {

    String toastText = "";
    private BluetoothDevice btDevice;
    private BluetoothSocket btSocket;
    private String btAddress = "11:22:33:44:44:44";
    String mArrayAdapter = "";
    private BluetoothAdapter mBluetoothAdapter = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void BTConnect (View v){

        mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
        if (mBluetoothAdapter == null) {
            Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
            finish();
            return;
        }
        else{

            toastText="Connecting to Mustang Sound Bluetooth receiver.... please wait";
            Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();
            BluetoothDevice device = mBluetoothAdapter.getRemoteDevice(btAddress);
            btSocket = device.createInsecureRfcommSocketToServiceRecord(UUID.fromString("0000111F-0000-1000-8000-00805F9B34FB"));
            btSocket.connect();

        }

    }



    public void LightsOn (View v){

        toastText="Sounds Lights On";
        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();

    }

    public void LightsOff (View v){

        toastText="Sounds Lights Off";
        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();

    }

    public void DoorsOpen (View v){

        toastText="Opening Sound doors";
        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();

    }

    public void DoorsClose (View v){

        toastText="Closing Sound doors";
        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();

    }

    public void SysOn (View v){

        toastText="IT'S ALIVE!!!!!.....IT'S ALIIIIIVEEEEEE";
        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();

    }

    public void SysOff (View v){

        toastText="Mustnag Sound OFF";
        Toast.makeText(MainActivity.this, toastText, Toast.LENGTH_SHORT).show();

    }



}

Answers


It seems that AndroidStudio/IntelliJ has a bug somewhere so java util jar is not added to compile classpath. Ironically - autocomplete works when typing import statement. Strange enough, in your case - for java.util.Set it worked out. Set might have been available elsewhere, while I've had the same issue for java.util.Date.

To me that happened on a brand new project, but the solution was to quit AndroidStudio, remove .iml file and .idea dir and reopen the project. After re-sync from gradle - all's good.


Need Your Help

How to create diagonal stripe patterns and checkerboard patterns?

matlab image-processing matrix textures modulation

Based on this question, I can confirm that horizontal patterns can be imposed onto a matrix (which in this case is an image), by multiplying it with a modulation signal created with this: