How to get my devices bluetooth Mac address in android [duplicate] - java

I'm trying to get the MAC address of bluetooth in my android device. So I'm using the following method:
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String macAddress = mBluetoothAdapter.getAddress();
The address returned is 02:00:00:00:00:00. I've seen questions and posts saying that it's not possible anymore to get your MAC address in android unless your application is a System Application.
So what if I really need to get the MAC address of my phone?? It's impossible to do it or what?
Note: I know this question is asked lots of times on SO, but most of the answers are out of date.

For security reasons this functionality is not available on Android since Android version 6.0 [source]:-
To provide users with greater data protection, starting in this
release, Android removes programmatic access to the device’s local
hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The
WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods
now return a constant value of 02:00:00:00:00:00.
The reason for this is to stop random applications gaining information about the phone's hardware addresses therefore violating the privacy/data protection.
I hope this helps.

What Youssif Saeed said in the other answer was correct. Android won't let us get the MAC address anymore.
Brief description about what I want:
Let's say I have a phone with MAC Address X, and I have another nearby device with MAC address B. When the two devices are nearby each other. I was able to get the MAC address of the other device using BluetoothDevice and getAddress() method from ScanResult.getDevice(). So what I still need is to catch my own device MAC address so that in the backend I save each user with his MAC address, and when I catch it in bluetooth, I know who's nearby me
Here's the workaround I've done in order to send some data between near devices.
I found something called Nearby Messages API. It is available for Android and iOS and very easy to implement. Now I'm able to catch near devices with my application installed on them, and send a unique Id generated by the application to identify the user.

Related

Get the MAC address of bluetooth adapter in Android

I'm trying to get the MAC address of bluetooth in my android device. So I'm using the following method:
BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
String macAddress = mBluetoothAdapter.getAddress();
The address returned is 02:00:00:00:00:00. I've seen questions and posts saying that it's not possible anymore to get your MAC address in android unless your application is a System Application.
So what if I really need to get the MAC address of my phone?? It's impossible to do it or what?
Note: I know this question is asked lots of times on SO, but most of the answers are out of date.
For security reasons this functionality is not available on Android since Android version 6.0 [source]:-
To provide users with greater data protection, starting in this
release, Android removes programmatic access to the device’s local
hardware identifier for apps using the Wi-Fi and Bluetooth APIs. The
WifiInfo.getMacAddress() and the BluetoothAdapter.getAddress() methods
now return a constant value of 02:00:00:00:00:00.
The reason for this is to stop random applications gaining information about the phone's hardware addresses therefore violating the privacy/data protection.
I hope this helps.
What Youssif Saeed said in the other answer was correct. Android won't let us get the MAC address anymore.
Brief description about what I want:
Let's say I have a phone with MAC Address X, and I have another nearby device with MAC address B. When the two devices are nearby each other. I was able to get the MAC address of the other device using BluetoothDevice and getAddress() method from ScanResult.getDevice(). So what I still need is to catch my own device MAC address so that in the backend I save each user with his MAC address, and when I catch it in bluetooth, I know who's nearby me
Here's the workaround I've done in order to send some data between near devices.
I found something called Nearby Messages API. It is available for Android and iOS and very easy to implement. Now I'm able to catch near devices with my application installed on them, and send a unique Id generated by the application to identify the user.

Check whether an app is installed in a paired device

Is there a way to search another devices installed application using bluetooth? Actual requirement is, is there a way to search the paired devices installed applications.
Any help is really appreciated.
Sorry, but this is not possible, unless you specifically have your own app on both sides and are somehow enabling this yourself. There is nothing built into Android to allow an arbitrary device to attack another arbitrary device (e.g., get at private information like installed applications).

Control a desktop application using an android phone

I want to build an application where an android phone would control a desktop application.
I only need to send coordinates from the phone to the desktop when user's finger is on the phone screen.
But I am kinda confused on the networking side if i should use bluetooth, usb, or wifi (intranet).
I did some research on bluetooth, doing bluetooth socket programming on an android phone shouldn't be a problem, but on the desktop side there are only a few free SDK/library. any suggestion on what to use?
If I were to use USB/cable, What API on the android side I need to use?
I am actually more familiar with general socket programming (wifi), but I think it's going to be slow (correct me if Im wrong) so this would be my last option.
PS: I am using Java for the desktop application too
any suggestions on what method to use? or even maybe I should use .net on the desktop side?
Thanks
You might find the open source RemoteDroid app to be useful in creating your app. It may even do everything that you want.
The source code is here. You may need an svn client like TortoiseSVN in order to download it.
Wifi is probably the most supportable.
Bluetooth requires hardware and drivers on the PC side
USB would ordinarily seem like the most sensible if the wire isn't a problem, but the catch is that it requires that the user enable "USB debugging" on the phone, and have either the android SDK or equivalent functionality to the adb forward command installed, plus a compatible USB driver for the phone. If all that were the case, you'd just forward a port from the PC to the phone and have a pc program connect to that port on the loopback interface which will be forwarded to a service running on the phone.
It's possible you could do something piggybacked on the USB tethering capability of more recent releases to get you a network-over-usb that you could use to connect programs on the PC and phone, but you'd need modified PC drivers so that you don't actually push the PC's internet traffic through the phone (unless you mean to tether as well).

Scan WiFi MAC addresses of mobile phones from java application

My application (not mobile application) needs to scan WiFi MAC addresses of mobile phones that are in my range.
For now I can only test it with my laptop. So I would like to connect my wireless card in laptop with my java application so application could scan for addresses. In near future, I will connect my application with different WiFi detector.
My WiFi card is Intel(R) PRO/Wireless 3945ABG Network Connection
Stackoverflow and google only shows results for android mobile development.
What API can you recommend?
This is tricky and maybe impossible, depending on precisely what you want - feel free to view this as a list of warnings or starting points, depending on how brave you feel :)
to obtain MAC addresses you need to capture raw packets, which isn't possible using pure Java; you'll need to use something like jNetPcap which wraps the (native) libpcap packet sniffing library
to determine whether a MAC address is likely to belong to a mobile phone, you'll need the list of Organizationally Unique Identifiers which links the first three bytes of a MAC address with the device manufacturer; mind that the OUI list might not be sufficient, since Apple (for instance) makes phones and other devices
to see all wireless traffic you'll need a driver that supports putting the wifi interface into monitor mode - these don't exist for all platforms/devices
the devices may not be sending any data...

How to interoperate between PC and camera from cell phone

My new project is to build an application to use the cell phone camera as the main camera from my PC.
How can I do this kind of stuff?
I thought of using bluetooth, but how my PC define the cell phone as the main camera?
Best reguards.
Depending on the camera phone and its features, you can do it. For my Bluetooth efforts, I've been using A7 hardware and a .NET library Blue Tools from Franson.
I've been able to:
pair devices in code
send/push images to the phone (probably the reverse would work, but I didn't try)
discover devices automagically
serial comm
network com
install as a network driver
Well on the Bluetooth side of things you might need a program running on you phone to forward the images. Or you might find that there's a Bluetooth program already running and providing that service, for instance the Bluetooth BASIC IMAGING PROFILE (BIP) (1) profile includes the usage scenario: "Use of a mobile phone to control the shutter of a digital still camera and immediately examine the result on the phone’s screen. In the present scenario, any other portable imaging device could play the role of the mobile phone."
So first you need to find if the phone supports BIP. You could for instance use the SdpBrowser sample application in my 32feet.NET .NET Bluetooth library to see what services the phone is advertising. Otherwise perhaps its documentation will tell you. You'd then have to find out whether the BIP service on your phone supports that scenario.
On the PC side you might need some driver level software to allow any application to use the remote camera. You might start by just allowing your own application alone to use the camera.

Categories

Resources