0

Is there a work around to check if the android app installed in the same device for the second time as well as the first installation date .Does Google Play Services provides api to fetch details pertaining to apps installation and uninstallation.

kaar3k
  • 994
  • 7
  • 15

3 Answers3

1

you can create your own server and when app installed on mobile, get the IMEI code and send to the server and store it in database . if the user again installed that app and when you get IMEI code on server compare and check whether IMEI exist or not . if exist he is installing again else he is installing for the very first time.

Waqar Ahmed
  • 5,005
  • 2
  • 23
  • 45
  • I am looking for a method which doesn't involve having a server.Any idea `google play services` provides a `api` to achieve this. – kaar3k Mar 27 '14 at 07:19
  • You can just store IMEI in the preferences. In OnCreate of main activity check it, if there is no - first start. – Alex Kucherenko Mar 27 '14 at 07:50
0

I didn't hear about such Play Services possabilities. But you can do it like @wqrahd told you or just, with out server part, create file on your external storage.

And to check if you are installing or updating application use SharedPreferences. They will not be removed after Application update so you can create some migration scheme and check it, like this :

public class MigrationManager {
    private final static String KEY_PREFERENCES_VERSION = "key_preferences_version";
    private final static int PREFERENCES_VERSION = 2;

    public static void migrate(Context context) {
        SharedPreferences preferences = context.getSharedPreferences("pref", Context.MODE_PRIVATE);
        checkPreferences(preferences);
    }

    private static void checkPreferences(SharedPreferences thePreferences) {
        final double oldVersion = thePreferences.getInt(KEY_PREFERENCES_VERSION, 1);

        if (oldVersion < PREFERENCES_VERSION) {
            final SharedPreferences.Editor edit = thePreferences.edit();
            edit.clear();
            edit.putInt(KEY_PREFERENCES_VERSION, currentVersion);
            edit.commit();
        }
    }
}

I wrote an article about Preferences where migration scheme is described. Cheers

Yakiv Mospan
  • 8,174
  • 3
  • 31
  • 35
0

I don't think Shared Preferences can solve this problem as if user can Clear Data from

Settings> applications> Manage application>

all data will be lost. Other solutions are needed.

Engineer
  • 1,436
  • 3
  • 18
  • 33
Lune
  • 1