简体   繁体   English

检查是否未安装Android应用,然后提示祝酒消息

[英]Check if Android app is not installed then prompt a toast message

Solved With This: how to open android application if installed and go to android market if not install 解决此问题: 如果已安装,如何打开android应用程序,如果未安装,如何进入android市场

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: 我的应用程序(主)是带有2个按钮的Web视图:

  1. Download the app from market (works correctly, html is < a href="inkstudio://market" >) 从市场下载该应用程序(工作正常,html为<a href =“ inkstudio:// market”>)

  2. Launch the app (html is < a href="inkstudio://lancia" >) 启动应用程序(html是<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. 如果按一下#1按钮(下载),则可以从PlayStore正确下载该应用程序;如果按按一下#2按钮,则下载的应用程序可以正确启动。

But if I press the button#2 when the app is not installed, I get a crash. 但是,如果在未安装应用程序时按按钮#2,则会崩溃。 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);
}

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? 如何以编程方式检查Android中是否安装了应用程序?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM