-9

I'm trying to get Device Id in following code

    public String getDevId() {
        String devId=android.telephony.TelephonyManager.getDeviceId();
        return devId;
    }

But it is saying "non static method 'getDeviceId()' cannot be referenced by static context"

Akhilesh Kumar
  • 8,525
  • 13
  • 52
  • 92

1 Answers1

4
public String getDeviceId(Context context){
    TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
      return telephonyManager.getDeviceId();
}
Vivart
  • 14,176
  • 5
  • 35
  • 70