I can't using the following method because my class doesn't extends the Activity class: Is there a unique Android device ID?
Try like this
import android.content.Context;
import android.provider.Settings.Secure;
public class sample {
public String getId(Context c)
{
String android_id = Secure.getString(c.getContentResolver(),
Secure.ANDROID_ID);
return android_id;
}
}
pass the context from your activity
sample s=new sample();
String udid=s.getId(getApplicationContext());
Toast.makeText(getApplicationContext(), udid, Toast.LENGTH_LONG).show();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With