Android for Work ANDROID_ID is returning NULL

1.8k views Asked by At

I'm using the following code to get the device id:

String androidID = Settings.Secure.getString(getActivity().getContentResolver(), Settings.Secure.ANDROID_ID);

According to the doc here, ANDROID_ID value is unique to each user. What I found is that the above string "androidID" is null when I tested my app under a managed profile (using BasicManagedProfile sample).

I'm assuming Android for Work is built on multi-user implementation. Why ANDROID_ID value is NULL here?

EDIT: Is there any other way to get device id from the work profile?

1

There are 1 answers

1
Jaymin On

Try this:

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                    Secure.ANDROID_ID);