In my Android app I wanna generate the device ID. At first I just generate the device ID inside an activity as below. It worked fine.
TelephonyManager tManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
String uid = tManager.getDeviceId();
return uid;
Then I wanna create a device object and try to do the above in it as a method,
public String generateDeviceId() {
// DeviceId = deviceId;
TelephonyManager tManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String uid = tManager.getDeviceId();
return uid;
}
It gives an syntax error and say
The method getSystemService(String) is undefined for the type Device
So how can I fix this. I wanna create a device class and create device object and do my stuff. Is it possible. I imported the below,
import android.content.Context;
import android.telephony.TelephonyManager;
So is it possible. Can someone help me to do my work. Thanks.