ScorpionGroup
ScorpionGroup

Reputation: 479

Bluetooth with Android

I'm new in android and I'm going to work with Bluetooth, but when I import bluetooth like the lines I express here:

import android.bluetooth.BluetoothAdapter;
import android.bluetooth.BluetoothDevice;
import android.bluetooth.BluetoothServerSocket;
import android.bluetooth.BluetoothSocket;

my SDK can not realize android.bluetooth . In addition, I add all packages and devices from "Android SDK and AVD Manager" but I still have problem. Could you help me to know how can I solve this problem. Thanks.

Upvotes: 1

Views: 4166

Answers (4)

Sebastien H.
Sebastien H.

Reputation: 7146

I had the same issue, to solve the problem, upgrade the android min required android version :

project/properties/android -> target name,

and select at least API version 7 (android 2.1) and of course add the bluetooth declarations in the manifest

Upvotes: 0

user1946049
user1946049

Reputation: 1

Open project properties, Android, Select your target

Upvotes: 0

David
David

Reputation: 1296

Taken from the developer website:

To perform Bluetooth communication using these APIs, an application must declare the BLUETOOTH permission. Some additional functionality, such as requesting device discovery, also requires the BLUETOOTH_ADMIN permission.

They import fine for me, perhaps you should run the software updater and ensure you've downloaded all the packages?

One last thing, the SDK cannot use the bluetooth package and you must test on a real device.

Upvotes: 2

Ramp
Ramp

Reputation: 1782

What kind of development environment do you use ? These packages and classes are in android.jar

If you have Eclipse plugin and SDK and create a android project , you will have to project include the android.jar and you should not have this problem.

If your environment is different, make sure that android.jar is in your CLASSPATH. It will be under platforms\android-2.1 where your SDK is installed. (assuming you are using android 2.1)

Upvotes: 1

Related Questions