// 안드로이드 기기 식별하는 36자의 String형 반환
private String GetDevicesUUID(Context mContext) {
final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
return deviceId;
}
위와 같은 코드를 같은 클래스에서는 GetDevicesUUID(this.getApplicationContext()) 하면 오류없이 불러와지는데
다른 클래스로 구현하여 (유지보수를 쉽게하기 위해)
public class Uuid extends Activity {
private String uuid;
// 안드로이드 기기 식별하는 36자의 String형 반환
public Uuid(Context mContext) {
// Context mContext = this.getApplicationContext();
final TelephonyManager tm = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
final String tmDevice, tmSerial, androidId;
tmDevice = "" + tm.getDeviceId();
tmSerial = "" + tm.getSimSerialNumber();
androidId = "" + android.provider.Settings.Secure.getString(getContentResolver(), android.provider.Settings.Secure.ANDROID_ID);
UUID deviceUuid = new UUID(androidId.hashCode(), ((long) tmDevice.hashCode() << 32) | tmSerial.hashCode());
String deviceId = deviceUuid.toString();
this.uuid = deviceId;
}
public String getUuid() {
return uuid;
}
}
와 같이 다른 클래스에 구현해 놓고,
Uuid u = new Uuid(this.getApplicationContext());
test = u.getUuid();
하면 프로그램이 죽어버림니다...
아무리 찾아도 방법을 모르겠어요 ㅠㅠ. 고수님들 부탁드립니다.
ps.manifast는 전부 정의 했습니다.