-1

I want to develop an application , which gives an offer like recharge .. etc ,when it is first time installed in the device. So should i do it with help of ip address

  • https://stackoverflow.com/questions/11392183/how-to-check-programmatically-if-an-application-is-installed-or-not-in-android – Satan Pandeya Sep 06 '17 at 05:33
  • 1
    device uuid / imei number would also be fine. – Exigente05 Sep 06 '17 at 05:40
  • Satan Pandeya, imagine the apps which give some money when u install them first time.If u install it again u should not get cash prize as the app is already installed in that particular device even though now it is deleted. – Bharadwaj Reddy Sep 06 '17 at 12:21

2 Answers2

1

You could use Shared Preferences to store a value on the device and you can check for it for every launch, this way you will able to know if its first time installed/launched.

https://developer.android.com/guide/topics/data/data-storage.html

If you intend to be more accurate, meaning its actually a first install and not a re-install, you will need to save:

  • the user information to your serve
  • the device information of that user

You will need to have user managements/accounts.

cheers.

alkathirikhalid
  • 887
  • 12
  • 18
  • sorry that will not work. Because as soon as i delete the app and reinstall it again, no data is stored in the mobile. So , we cannot find it with shared preferences. – Bharadwaj Reddy Sep 06 '17 at 12:17
  • Yes correct as I mentioned "If you intend to be more accurate, meaning its actually a first install and not a re-install, you will need to save.. Server:" You will need to have a server/cloud database. Example: https://firebase.google.com/docs/database/ – alkathirikhalid Sep 07 '17 at 03:05
0
public static boolean isAppInstalled(Context context, String pkgName) {
    try {
        context.getPackageManager().getApplicationInfo(pkgName, 0);
        return true;
    }
    catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}
Saurabh Deshmukh
  • 163
  • 1
  • 15
  • 1
    While this code snippet may solve the problem, it doesn't explain why or how it answers the question. Please include an explanation for your code, as that really helps to improve the quality of your post. Remember that you are answering the question for readers in the future, and those people might not know the reasons for your code suggestion – Balagurunathan Marimuthu Sep 06 '17 at 06:27
  • You Know Jio Application right. There when u install application for the first time on a 4g mobile , it generates a barcode only first time .If u uninstall the application and again install in it, u will not get that barcode . I need some thing like this. Can u help me with this.Thanks in advance – Bharadwaj Reddy Sep 07 '17 at 10:23