[mono-android] How to get UID using getContentResolver

Tommy Hinrichs tommy.hinrichs at gmail.com
Wed Mar 23 00:14:52 EDT 2011


The hint to the answer here is this snippet from the documentation [0] "You
get a ContentResolver by calling
getContentResolver()<http://developer.android.com/reference/android/content/Context.html#getContentResolver()>
from
within the implementation of an Activity".

So, assuming you are within the context of an Activity, the following line
of code should be what you want.

using Android.Provider;

...

var deviceId = Settings.Secure.GetString(ContentResolver,
Settings.Secure.AndroidId);



* Note that ContentResolver above is really this.ContentResolver, but
persuant to general c# standards I left it out.

Then I thought maybe it would be clearer if I added this note since
you were specifically asking where the ContentResolver property lives.


[0]
http://developer.android.com/guide/topics/providers/content-providers.html the
de

On Tue, Mar 22, 2011 at 8:22 PM, <www at gencode.com> wrote:

> I am trying to get the unique id of the device.
>
>
>
> import android.provider.Settings.Secure;
>
> private String android_id =
> Secure.getString(getContext().getContentResolver(),
>
>
> Secure.ANDROID_ID);
>
>
>
>
>
> I could not find the getContentResolver method
>
> I got this so far
>
> Android.Provider.Settings.Secure.GetString(????
>
>                           Android.Provider.Settings.Secure.AndroidId);
>
>
>
>
>
> What am I missing in the ??? as I could not resolve the method
> getContentResolver()
>
>
>
>
>
> _______________________________________________
> Monodroid mailing list
> Monodroid at lists.ximian.com
>
> UNSUBSCRIBE INFORMATION:
> http://lists.ximian.com/mailman/listinfo/monodroid
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/mailman/private/monodroid/attachments/20110322/004a1928/attachment.html 


More information about the Monodroid mailing list