标签:
TelephonyManager tm =(TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);String DEVICE_ID = tm.getDeviceId();
import android.provider.Settings;String ANDROID_ID =Settings.System.getString(getContentResolver(),Settings.System.ANDROID_ID);
StringSerialNumber= android.os.Build.SERIAL;
1 publicclassInstallation{ 2 privatestaticString sID =null; 3 privatestaticfinalString INSTALLATION ="INSTALLATION"; 4 publicsynchronizedstaticString id(Context context){ 5 if(sID ==null){ 6 File installation =newFile(context.getFilesDir(), INSTALLATION); 7 try{ 8 if(!installation.exists()) 9 writeInstallationFile(installation); 10 sID = readInstallationFile(installation); 11 } 12 catch(Exception e){ 13 thrownewRuntimeException(e); 14 } 15 } 16 return sID; 17 } 18 privatestaticString readInstallationFile(File installation)throwsIOException{ 19 RandomAccessFile f =newRandomAccessFile(installation,"r"); 20 byte[] bytes =newbyte[(int) f.length()]; 21 f.readFully(bytes); f.close();returnnewString(bytes); 22 } 23 privatestaticvoid writeInstallationFile(File installation)throwsIOException{ 24 FileOutputStream out =newFileOutputStream(installation); 25 String id = UUID.randomUUID().toString(); out.write(id.getBytes()); 26 out.close(); 27 } 28 }
标签:
原文地址:http://www.cnblogs.com/fruitbolgs/p/4747854.html