在App中打开淘宝

什么都不说了直接上代码

/**   * 检测该包名所对应的应用是否存在   * @param packageName   * @return   */
    public boolean checkPackage(String packageName)  {
        if (packageName == null || "".equals(packageName))
            return false;
        try    {
            UIUtils.getContext().getPackageManager().getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
            return true;
        } catch (PackageManager.NameNotFoundException e)   {
            return false;
        }
    }
if(checkPackage("com.taobao.taobao")){
//打开App
                    Intent intent = new Intent();
                    intent.setAction("android.intent.action.VIEW");
                    String url = "taobao://shop.m.taobao.com/shop/shop_index.htm?shop_id=131259851&spm=a230r.7195193.1997079397.8.Pp3ZMM&point" +
                            "=%7B%22from%22%3A%22h5%22%2C%22url%22%3A%22http%3A%2F%2Fshop131259851.m.taobao.com%2F%22%2C%22h5_uid%22%3A%22aJHIDr" +
                            "hLh0cCAYYbRtrrS3Ut%22%2C%22uaPoint%22%3A%22Mozilla%2F5.0%2520(Linux%3B%2520Android%25205.0.1%3B%2520SM-N9109W%2520Bui" +
                            "ld%2FLRX22C%3B%2520wv)%2520AppleWebKit%2F537.36%2520(KHTML%2C%2520like%2520Gecko)%2520Version%2F4.0%2520Chrome%2F43" +
                            ".0.2357.121%2520Mobile%2520Safari%2F537.36%2520Rong%2F2.0%22%7D";
                    Uri uri2 = Uri.parse(url);
                    intent.setData(uri2);
                    startActivity(intent);
                }else{
                //网页打开
                     Intent intent2 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://zmnxbc.com/s/g6TFj?tm=1755c7"));
                if (isAppInstalled(getActivity(), "com.taobao.tao.shop.router.ShopUrlRouterActivity")) {
                    intent2.setClassName("com.taobao.taobao", "com.taobao.tao.shop.router.ShopUrlRouterActivity");
                }
                startActivity(intent2);
                }

你可能感兴趣的:(知识点,淘宝网,应用,app)