【问题标题】:Check and Install other application from other android检查并安装来自其他 android 的其他应用程序
【发布时间】:2012-12-13 09:13:54
【问题描述】:

我想创建一个小应用程序,当我在主要活动中启动这个小应用程序时,我想检查我的手机上是否安装了其他应用程序,例如“条形码”。

  • 如果是,我想启动应用程序“条形码”
  • 如果没有,我想从 google play 安装此应用程序。

我该怎么做?

【问题讨论】:

    标签: android


    【解决方案1】:

    如果安装了应用程序,请检查以下代码

    PackageManager pm = getPackageManager();
    boolean app_installed = false;
    try
    {
         pm.getPackageInfo("com.package.Barcode", PackageManager.GET_ACTIVITIES);
         app_installed = true;
    }
    catch (PackageManager.NameNotFoundException e)
    {
         app_installed = false;
    }
    return app_installed ;
    

    以下代码将用户重定向到 Play 商店以下载应用程序

    String appName = "com.package.Barcode";    
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id="+appName));
    startActivity(intent);
    

    【讨论】:

      【解决方案2】:

      如何打开您可以在此处找到的现有应用:

      Open another application from your own (intent)

      以及如何检查应用程序是否存在您可以在这里找到:

      How can I learn whether a particular package exists on my Android device?

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-04-05
        • 1970-01-01
        • 1970-01-01
        • 2012-08-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多