java - How can I get the android device id which I get on dialing " *#*#8255#*#* " -


this question has answer here:

how can android device id on dialing *#*#8255#*#*

i using following code not return same...what want

string android_id = secure.getstring(getactivity()                 .getcontentresolver(), secure.android_id); 

enter image description here

i think code tried returns dynamic id. try this.

private static final uri uri = uri.parse("content://com.google.android.gsf.gservices"); private static final string id_key = "android_id";

   string getandroidid(context ctx) {        string[] params = { id_key };        cursor c = ctx.getcontentresolver()                .query(uri, null, null, params, null);        try{         if (!c.movetofirst() || c.getcolumncount() < 2){            return null;        }        }catch(exception e){            return null;        }         try {            toast.maketext(ctx, long.tohexstring(long.parselong(c.getstring(1))), 500).show();            system.out.println("android id  " + long.tohexstring(long.parselong(c.getstring(1))));             return long.tohexstring(long.parselong(c.getstring(1)));         } catch (numberformatexception e) {            return null;        }    } 

in above code long.tohexstring(long.parselong(c.getstring(1))), returns android device id.


Comments

Popular posts from this blog

Change php variable from jquery value using ajax (same page) -

Pull out data related to my apps from Android Play Store and iOS App Store -

How can I fetch data from a web server in an android application? -