0

I am currently developing an app that can open my other app within a button click. However, when the targeted app is not already installed, the app will crash and force close. How do I set it up so that it shows up a dialog and gives a link to install the app?

borislemke
  • 8,446
  • 5
  • 41
  • 54

1 Answers1

0

What you want to do is query the installed packages via an intent call as seen here: How to get a list of installed android applications and pick one to run. Then just cycle through the list and see if your app is there.

Community
  • 1
  • 1
ahodder
  • 11,353
  • 14
  • 71
  • 114
  • Thats not the main problem. What I want is the activity to open up a dialog when the package is not installed. I know theres a method like "if package is opened, done", "if else, show dialog"(something like that). I will need to use this in future projects also. But thanks for the comment. – borislemke Jan 06 '12 at 21:12
  • @borislemke Right, you use the above method to discover whether or not a package is installed. Then open your dialog as you say to inform the user that the package is not installed. Also, in reference to your third sentence, there is a huge distinction between "installed" and "open". What do you want the trigger to be? Open or installed? – ahodder Jan 06 '12 at 21:28
  • If the app is already installed, it should be OPENing the app. But when the app is not present, it should open a dialog that gives the user an option to install the app via a market link. – borislemke Jan 07 '12 at 13:41
  • Thanks anyway, I'll to do with ur method. Hope I'll get it to work – borislemke Jan 07 '12 at 13:41
  • Anyway, there shouldnt be a need to scroll through a list, everything should work automatically. – borislemke Jan 07 '12 at 13:52
  • Yes, and you have to program the automatically. If you then want it to start the already installed app, you just call its intent, I believe. – ahodder Jan 09 '12 at 03:22