Go To ( http://adf.ly/20PrE )-)-) [android-developers] Wi-fi MAC address as unique ID

2 views
Skip to first unread message

RLScott

unread,
Dec 5, 2011, 8:03:18 PM12/5/11
to Android Developers
My app will not be distributed through the Marketplace but directly by
me. And I have a licensing method that relies on a unique ID in the
device. I realize that this means customers will have to contact me
for a new activation if they switch devices and that is OK. But I
don't want to make the customer go through that trouble if they just
happen to reinitialize their device. If I used the Android_ID as my
unique ID then reinitializing a device would produce a different
Android_ID. So I don't want to use that. I also don't want to use
the IMEI of the phone for several reasons. One is that some devices
are not phones. The other is that people are suspicious of apps that
declare the need to access the telephony stack. So that leaves the wi-
fi MAC address.

One problem with the wi-fi MAC address is that on some devices (so I
hear) the MAC address is not available from the WiFiManager if wi-fi
happens to be turned off. Therefore I intend to prompt the user to
turn on wi-fi during the licensing process if it is not already on.
And if the device does not have wi-fi, then I intend to fall back to
the Android_ID as my unique identifier.

With all that said, I would like to know how to tell when the MAC
address is unavailable. The devices that I have tested on all yield
up a MAC address even when wi-fi is turned off, so I am not fortunate
enough to own one of those troublesome devices. So for those devices
I would like to know what to expect. Here is how I get the wi-fi MAC
address:

WifiManager wfManager;
WifiInfo wifiinfo;
wfManager = (WifiManager)getSystemService(Context.WIFI_SERVICE);
wifiinfo = wfManager.getConnectionInfo();
String macAddr = wifiinfo.getMacAddress();

So my question is what should I expect this code to do when running on
a device that "fails" to return the MAC address when wi-fi is turned
off. (Exception? Null string?). Also what should I expect this code
to do on a device that does not have wi-fi hardware?

--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-d...@googlegroups.com
To unsubscribe from this group, send email to
android-develop...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

--
Go to Master Mind Home Base Income Website :-

http://adf.ly/20PrE

http://adf.ly/20PrE

Unsubscribe All Group Post :- http://j.gs/624707/unsubscribe

http://q.gs/624707/unsubscribe

Subscribe All Group Post :- http://j.gs/624707/subscribe

http://q.gs/624707/subscribe

Join Now Today (Paid Income) :-

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/?id=624707

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

http://adf.ly/20PrE

lbendlin

unread,
Dec 5, 2011, 8:07:50 PM12/5/11
to android-d...@googlegroups.com
try the following. Reboot the device with wifi off, and then run your code. You will see how the device behaves.

What you have seen so far is just a mean way of caching. When Wifi is on, the MAC address is remembered by the system even if you then switch WiFi off.

RLScott

unread,
Dec 5, 2011, 8:54:45 PM12/5/11
to Android Developers

On Dec 5, 8:07 pm, lbendlin <l...@bendlin.us> wrote:
> try the following. Reboot the device with wifi off, and then run your code.
> You will see how the device behaves.
>
> What you have seen so far is just a mean way of caching. When Wifi is on,
> the MAC address is remembered by the system even if you then switch WiFi
> off.

Yes! Super. I get null for wifiinfo.getMacAddress()

OK, now I know what to expect in that situation. But what will I see


on a device that does not have wi-fi hardware?

--

lbendlin

unread,
Dec 6, 2011, 7:03:22 AM12/6/11
to android-d...@googlegroups.com
Most likely a null pointer exception.

RLScott

unread,
Dec 6, 2011, 3:41:27 PM12/6/11
to Android Developers
Still looking for a way to distinguish between:

1. wi-fi turned off
2. no wi-fi hardware present on this device

Kostya Vasilyev

unread,
Dec 6, 2011, 3:59:17 PM12/6/11
to android-d...@googlegroups.com
Have you tried:

http://developer.android.com/reference/android/content/pm/PackageManager.html#FEATURE_WIFI

???

7 декабря 2011 г. 0:41 пользователь RLScott <fixtha...@yahoo.com> написал:

RLScott

unread,
Dec 6, 2011, 4:45:42 PM12/6/11
to Android Developers
Thanks. That is exactly what I needed.

On Dec 6, 3:59 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> Have you tried:
>
> http://developer.android.com/reference/android/content/pm/PackageMana...
>
> ???
>
> 7 ÄÅËÁÂÒÑ 2011šÇ. 0:41 ÐÏÌØÚÏ×ÁÔÅÌØ RLScott <fixthatpi...@yahoo.com> ÎÁÐÉÓÁÌ:

Reply all
Reply to author
Forward
0 new messages