zoukankan      html  css  js  c++  java
  • android 判断应用程序是否已安装

    1、判断是否安装
    /*
    * check the app is installed
    */
    private boolean isAppInstalled(Context context,String packagename)
    {
    PackageInfo packageInfo;        
    try {
                packageInfo = context.getPackageManager().getPackageInfo(packagename, 0);
             }catch (NameNotFoundException e) {
                packageInfo = null;
                e.printStackTrace();
             }
             if(packageInfo ==null){
                //System.out.println("没有安装");
                return false;
             }else{
                //System.out.println("已经安装");
                return true;
            }
    }


    2、判断后的逻辑: (转自:http://ruixiazun.blog.163.com/blog/static/906879182013021115923732/)
    //已安装,打开程序,需传入参数包名:"com.skype.android.verizon" 
    if(isAvilible(this, "com.skype.android.verizon")){ 
                    Intent i = new Intent(); 
                    ComponentName cn = new ComponentName("com.skype.android.verizon", 
                            "com.skype.android.verizon.SkypeActivity"); 
                    i.setComponent(cn); 
                    startActivityForResult(i, RESULT_OK);    
                } 
    //未安装,跳转至market下载该程序 
    else { 
                    Uri uri = Uri.parse("market://details?id=com.skype.android.verizon");//id为包名 
                    Intent it = new Intent(Intent.ACTION_VIEW, uri); 
                    startActivity(it); 
                }

  • 相关阅读:
    [转]oracle 12c 中的分页子句
    display:table; 也可以实现 div 始终和内包的图片大小相同
    mongodb与SQL常见语句对照
    js生成验证码
    javascript 判断空数组
    网络绘制插件
    mongodb中查询返回指定字段
    Mybatis获取插入记录的自增长ID
    mysql 创建索引和删除索引
    Java 中 HashMap 初始化时赋值
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/5669286.html
Copyright © 2011-2022 走看看