2017-03-17 1 views
0

기기에 구매 항목을 1 개로 제한하는 앱 기능이 있습니다. 아래 코드를 사용하여 기기별로 고유 ID를 생성 중입니다. 사용자가 병렬 공간 앱에서 앱을 설치할 때 다른 코드가 어떻게 생성되는지 어쨌든 추적 할 수 있습니까?평행 공간 앱에서 내 앱에 액세스하는 사용자를 추적하는 방법은 무엇입니까?

고유 ID 생성에 대한 나의 코드 :

public String getUniqueDeviceId() { 
     String deviceID = null; 
     String androidID = sessionManager.getUniqueID().get("uniqueid"); 
     if(androidID!=null) 
     { 
      if(androidID.length()>0) 
      { 
       return androidID; 
      } 
      else 
      { 
       String uniqueId = ""; 
       //TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); 
       //uniqueId = uniqueId.concat(TelephonyMgr.getDeviceId()); 
       String buildParams = "99" + 
         Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + 
         Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + 
         Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + 
         Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + 
         Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + 
         Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + 
         Build.USER.length() % 10; 
       uniqueId = uniqueId.concat(buildParams); 
       uniqueId = uniqueId.concat(Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID)); 
       WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); 
       uniqueId = uniqueId.concat(wm.getConnectionInfo().getMacAddress()); 
//    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
//    uniqueId = uniqueId.concat(mBluetoothAdapter.getAddress()); 
       // Initiate digest with MD5 
       MessageDigest mDigest = null; 
       try { 
        mDigest = MessageDigest.getInstance("MD5"); 
       } catch (NoSuchAlgorithmException e) { 
        e.printStackTrace(); 
       } 
       mDigest.update(uniqueId.getBytes(), 0, uniqueId.length()); 
       byte[] digestedBytes = mDigest.digest(); 
       String deviceId = ""; 
       for (int i = 0; i < digestedBytes.length; i++) { 
        int b = (0xFF & digestedBytes[i]); 
        // Additional Padding 
        if (b <= 0xF) { 
         deviceId += "0"; 
        } 
        // concat at the end 
        deviceId = deviceId.concat(Integer.toHexString(b)); 
       } 
       deviceID = deviceId.substring(0, 24); 
       sessionManager.createUniqueID(deviceID); 
       return deviceID; 
      } 
     } 
     else 
     { 
      String uniqueId = ""; 
      //TelephonyManager TelephonyMgr = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); 
      //uniqueId = uniqueId.concat(TelephonyMgr.getDeviceId()); 
      String buildParams = "99" + 
        Build.BOARD.length() % 10 + Build.BRAND.length() % 10 + 
        Build.CPU_ABI.length() % 10 + Build.DEVICE.length() % 10 + 
        Build.DISPLAY.length() % 10 + Build.HOST.length() % 10 + 
        Build.ID.length() % 10 + Build.MANUFACTURER.length() % 10 + 
        Build.MODEL.length() % 10 + Build.PRODUCT.length() % 10 + 
        Build.TAGS.length() % 10 + Build.TYPE.length() % 10 + 
        Build.USER.length() % 10; 
      uniqueId = uniqueId.concat(buildParams); 
      uniqueId = uniqueId.concat(Settings.Secure.getString(getApplicationContext().getContentResolver(), Settings.Secure.ANDROID_ID)); 
      WifiManager wm = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE); 
      uniqueId = uniqueId.concat(wm.getConnectionInfo().getMacAddress()); 
//   BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); 
//   uniqueId = uniqueId.concat(mBluetoothAdapter.getAddress()); 
      // Initiate digest with MD5 
      MessageDigest mDigest = null; 
      try { 
       mDigest = MessageDigest.getInstance("MD5"); 
      } catch (NoSuchAlgorithmException e) { 
       e.printStackTrace(); 
      } 
      mDigest.update(uniqueId.getBytes(), 0, uniqueId.length()); 
      byte[] digestedBytes = mDigest.digest(); 
      String deviceId = ""; 
      for (int i = 0; i < digestedBytes.length; i++) { 
       int b = (0xFF & digestedBytes[i]); 
       // Additional Padding 
       if (b <= 0xF) { 
        deviceId += "0"; 
       } 
       // concat at the end 
       deviceId = deviceId.concat(Integer.toHexString(b)); 
      } 
      deviceID = deviceId.substring(0, 24); 
      sessionManager.createUniqueID(deviceID); 
      return deviceID; 
     } 
    } 
사용할 수
+0

당신을 가지고 접근의 권한을 부여 할 수 없습니다 이것에 대한 해결책을 찾았습니다. 나는 또한 같은 것을 찾고 있습니다 ... @Anirudh –

+0

@AnkitKumarSingh 아니요, 해결책을 찾지 못했습니다. – Anirudh

+0

앱에 로그인되어 있습니까? – mrid

답변

관련 문제