0

Solved With This: how to open android application if installed and go to android market if not install

I need to check if an app is installed before start it, and if not prompt the user a toast message like "The app is not installed, please press on the Download from market" or automatically link to market.

My app (main) is a webview with 2 buttons:

  1. Download the app from market (works correctly, html is < a href="inkstudio://market" >)

  2. Launch the app (html is < a href="inkstudio://lancia" >)

If I press the button #1 (download) I can download correctly the app from the PlayStore, and if I press the button #2 the downloaded app start correctly.

But if I press the button#2 when the app is not installed, I get a crash. How can i prevent this?

My code is:

if(url.equals("inkstudio://market")){
    Intent lancia = new Intent(Intent.ACTION_VIEW);
    lancia.setData(Uri.parse("market://details?id=com.aurasma.aurasma"));
    startActivity(lancia);
}
if(url.equals("inkstudio://lancia")){
    Intent lancia = new Intent(Intent.ACTION_VIEW);
    lancia.setData(Uri.parse("aurasma://?YXVyYXNtY"));
    startActivity(lancia);
}
Community
  • 1
  • 1
vonatar
  • 64
  • 7
  • take a look of this: http://stackoverflow.com/questions/11392183/how-to-check-if-the-application-is-installed-or-not-in-android-programmatically – Tobiel Sep 04 '13 at 19:56

1 Answers1

1

You need to search in the installed applications programmatically in the device. take a look of this:
How to check programmatically if an application is installed or not in Android?

Community
  • 1
  • 1
Tobiel
  • 1,495
  • 12
  • 19