-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
  • 9,085
  • 13
  • 57
  • 95

1 Answers1

4
public String getDeviceId(Context context){
    TelephonyManager telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE);
      return telephonyManager.getDeviceId();
}
Vivart
  • 14,900
  • 6
  • 36
  • 74