0

Is there any way (intent) to know if my application is installed ? I followed the below link, but my application don't get the intent when my app is installed

Android - How to intercept the 'Install application' intent

Community
  • 1
  • 1
Shri
  • 1,223
  • 5
  • 22
  • 31

2 Answers2

4

If you want to execute any code from app A, it has to be already installed (it's obvious, isn't it?), so you can't check from your app A whether your app APP is installed or not.

It's like if you want to know when you are dead: after you die, it will be impossible to know it. On the other hand, someone else can know when you die... same for the Android scenario: an app B can know whether app A is installed or not (by using getInstalledPackages or intents or whatever).

J.G.Sebring
  • 5,934
  • 1
  • 31
  • 42
Cristian
  • 198,401
  • 62
  • 356
  • 264
  • Actually, the use case is. My App doesn't have icon in app launcher. Basically I want to start the service immediately after the app gets installed (User will not start my app) – Shri Dec 02 '10 at 11:41
  • Then, you can try to intercept some external intent with a `BroadcastReceiver`. Not sure if you can intercept `android.intent.action.PACKAGE_ADDED`... but I know you can intercept something like the Boot intent (in that case you would have to wait until the user reboot the phone, though). You can search for any other intent that you can use once, just to start the service. – Cristian Dec 02 '10 at 13:14
  • android.intent.action.PACKAGE_ADDED can't be received self , it will notify only in case is any other app installs the app – Shri Dec 02 '10 at 14:28
  • Good to know that, thanks. You will have to use other intent then :) – Cristian Dec 02 '10 at 15:38
0

You can use http://developer.android.com/reference/android/content/pm/PackageManager.html#getInstalledPackages(int)

Remember to set the appropriate permission in your AndroidManifest.

You quoted the link to Android - How to intercept the 'Install application' intent - which would mean you like to know when you application was installed at all? Are you trying to check if people actually download your app? Basically I think it's not possible to do that.

But if you like to see if your app was installed, just check for a SharedPreference and if not possible, it's a fresh install.

Community
  • 1
  • 1
Sebastian Roth
  • 11,344
  • 14
  • 61
  • 110
  • I just want to know if my app is installed , I mean fresh install use case is when my app gets installed I want to register to content observer so I want to know how this can be done – Shri Dec 01 '10 at 11:37
  • The fresh install test in this answer seems reasonable. You could also do something on first install and then set a flag somewhere, and not do it again if you see that flag already set. – Chris Stratton Dec 01 '10 at 15:23
  • IS there any way I can check for the fresh install? – Shri Dec 01 '10 at 16:10
  • Write a shared preference and read it. If it's not available on your programs start it is fresh. Remember if a user deletes your app and reinstalls it, this counts fresh too. – Sebastian Roth Dec 10 '10 at 18:11