处理Google Play的相关方法

1.打开Google play软件的详细页面

         Intent intent = new Intent();

            intent.setAction(Intent.ACTION_VIEW);

            intent.setData(Uri.parse("market://details?id=" + content.getPackageName()));

            content.startActivity(intent);

 

 

2. 获取obb文件目录的方法

 

private final static String EXP_PATH = "/Android/obb/";

    public static String getObbDirectory()
    {
        String packageName = RoN.actInstance.getPackageName();
        if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED))
        {
            // Build the full path to the app's expansion files
            File root = Environment.getExternalStorageDirectory();
            File expPath = new File(root.toString() + EXP_PATH + packageName);
            if (!expPath.exists())
            {
                //如果目录不存在,则创建一个
                expPath.mkdirs();
            }
            if (expPath.isDirectory())
            {
                return expPath.getPath();
            }
            return "";
        }
        return "";        
    }
    
    public static String getObbFileName()
    {
        PackageInfo info = null;
        try 
        {
            info = RoN.actInstance.getPackageManager().getPackageInfo(RoN.actInstance.getPackageName(), 0);
            return "main." + info.versionCode + "." + RoN.actInstance.getPackageName() + ".obb";
        } 
        catch (NameNotFoundException e) 
        {
            e.printStackTrace();
        }
        return "";
    }
    
    public static String getVirtualObbFileFullpath()
    {
        return getObbDirectory() + File.separator + getObbFileName();
    }

    public static boolean isObbFileExist() 
    {
        String pp = getVirtualObbFileFullpath();
        File main = new File(pp);
        return main.isFile();
    }

 

posted @ 2014-04-16 13:09  haroel  阅读(363)  评论(0编辑  收藏  举报