2

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?

Ziem
  • 6,579
  • 8
  • 53
  • 86
Song
  • 504
  • 7
  • 17

1 Answers1

-1

Try this:

private String android_id = Secure.getString(getContext().getContentResolver(),
                                                    Secure.ANDROID_ID); 
Pang
  • 9,564
  • 146
  • 81
  • 122
Jaymin
  • 2,879
  • 3
  • 19
  • 35
  • Thank you for your answer. Actually the code in my original post is working fine now. Not sure why is that. Your code is basically the same as mine? Secure is from android.provider.Settings. – Song Feb 29 '16 at 19:40