如何跟踪从并行空间应用访问我的应用的用户?

时间:2017-03-17 09:33:43

标签: android uniqueidentifier

我的应用中有一项功能,限制每台设备的购买量为1。 我使用以下代码为每台设备生成一个唯一的ID。当用户从Parallel Space App安装应用程序时,如何生成不同的代码。无论如何我能跟踪吗?

我的代码用于生成唯一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;
        }
    }

1 个答案:

答案 0 :(得分:0)

您可以使用辅助功能服务

喜欢这些应用 - http://share.tbal.io/v2/app?code=23UHRFC7

并行空间无法授予可访问性