• 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); 
                }

  • 相关阅读:
    python正则表达式基础,以及pattern.match(),re.match(),pattern.search(),re.search()方法的使用和区别
    python正则表达式--分组、后向引用、前(后)向断言
    python正则表达式--flag修饰符、match对象属性
    mybatis-核心配置文件和mappe.xml
    mybatis mapper标签
    spring JdbcTemplate 常用的自定义工具包
    web基础
    8.24 JDBC 调用存储过程
    8.24 事务处理
    8.24 批处理
  • 原文地址:https://www.cnblogs.com/Free-Thinker/p/5669286.html
Copyright © 2020-2023  润新知