-4

I am working with some affiliate marketing companies and I need to promote my android app through them, but for that I need to check whether installation of my app is unique or not. I need to give some amount per installation, in order to do that properly, I need to identify if installation is unique or not, if it is unique then only release money otherwise not.

WHAT I HAVE DONE : I was using ANDROID_ID to check if installation is unique or not, but I came to know it is not unique, it changes with every system upgrade/root of the device, so I will not be able to determine unique installation if someone has rooted his device and installed my app again.

I have also checked IMEI thing, but there can be cases when people may use tablets etc to install apps, in some cases there is no IMEI, please refer

I have seen this working properly with some applications such as Flipkart. Any ideas?

Community
  • 1
  • 1
Alok Gupta
  • 1,353
  • 1
  • 13
  • 29

2 Answers2

1

Please refer this link:

http://android-developers.blogspot.in/2011/03/identifying-app-installations.html

There are various approaches suggested :

1:

public class Installation {
    private static String sID = null;
    private static final String INSTALLATION = "INSTALLATION";

    public synchronized static String id(Context context) {
        if (sID == null) {  
            File installation = new File(context.getFilesDir(), INSTALLATION);
            try {
                if (!installation.exists())
                    writeInstallationFile(installation);
                sID = readInstallationFile(installation);
            } catch (Exception e) {
                throw new RuntimeException(e);
            }
        }
        return sID;
    }

    private static String readInstallationFile(File installation) throws IOException {
        RandomAccessFile f = new RandomAccessFile(installation, "r");
        byte[] bytes = new byte[(int) f.length()];
        f.readFully(bytes);
        f.close();
        return new String(bytes);
    }

    private static void writeInstallationFile(File installation) throws IOException {
        FileOutputStream out = new FileOutputStream(installation);
        String id = UUID.randomUUID().toString();
        out.write(id.getBytes());
        out.close();
    }
}

and i say use,

ANDROID_ID since it works pretty reliably for newer devices

JAAD
  • 12,349
  • 7
  • 36
  • 57
1

I've been languishing on the internet to find an answer to the same problem. It appears getting something truly unique is very difficult.

1) Android_ID is returned either NULL or random shit 'with a major manufacturer` 2) telephonyManager.getDeviceId() is returned null with devices without sim card capabilities.

The best you can do is get IMEI number (.getDeviceId()) for devices where it is available and ANDROID_ID for devices when its not. You could at least, minimise your losses with having to roll out money only for devices without sim card facility which are rooted. Trust me, that's a very minor number.

References : This link should help.

Note : Too big to post as a comment.

Community
  • 1
  • 1
Clinkz
  • 716
  • 5
  • 18