Android 从代码中打开淘宝和亚马逊、facebook、Message

Android 中打开淘宝和亚马逊店铺首页、facebook、Message
// 打开手淘
   private void openTaobaoShopping() {
        if (checkPackage( "com.taobao.taobao")) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            String url = "taobao://shop.m.taobao.com/shop/shop_index.htm?shop_id=589316535";
            Uri uri = Uri.parse(url);
            intent.setData(uri);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setClassName("com.taobao.taobao", "com.taobao.android.shop.activity.ShopHomePageActivity");
            startActivity(intent);
        } else {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            Uri  content_url = Uri.parse("https://gyroor.tmall.com/shop/view_shop.htm?spm=a230r.1.14.24.100b4c683ZQt3U&user_number_id=3555679835");
            intent.setData(content_url);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(intent);
        }
    }




// 打开亚马逊(注意亚马逊的配置,若是收货地址没有在店铺站点发布范围内是打不开的,美国邮编:91730)
    intent.setAction("android.intent.action.VIEW");
                    content_url = Uri.parse("https://www.amazon.com/s/browse/ref%3Dbl_dp_s_mapp_17442926011?ie=UTF8&node=17442926011&field-lbr_brands_browse-bin=Gyroor");
                    intent.setData(content_url);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    startActivity(intent);

 

//  打开Facebook
    private void goFacebook(){
        // 跳转到facebook
        Intent intent = new Intent();

        PackageManager packageManager = MallActivity.this.getPackageManager();
        intent = packageManager.getLaunchIntentForPackage("com.facebook.katana");     // 判断是否有安装facebook
        if (intent == null) {  // 没有facebook时用浏览器打开
            Intent intent2 = new Intent();
            intent2.setData(Uri.parse("https://www.facebook.com/Gyroor/"));
            intent2.setAction(Intent.ACTION_VIEW);
            startActivity(intent2); //启动浏览器
        } else {
            intent =new Intent();
            String facebookUrl =DiscoverActivity.getFacebookPageURL(MallActivity.this);
            if (facebookUrl.equals("PackageManager.NameNotFoundException")){
                intent.setData(Uri.parse("https://www.facebook.com/Gyroor/"));
                intent.setAction(Intent.ACTION_VIEW);
            }else {
                intent.setAction("android.intent.action.VIEW");
                intent.setData(Uri.parse(facebookUrl));
            }
            startActivity(intent);
        }
    }

 

    /**
     * 打开Messenger App
     *  */
    private  void openMessger2() {
        if (checkPackage("com.facebook.orca")) {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            String url = "http://m.me/Gyroor";
            Uri uri = Uri.parse(url);
            intent.setData(uri);
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            intent.setClassName("com.facebook.orca", "com.facebook.messenger.intents.IntentHandlerActivity");
            startActivity(intent);
        } else
            {
            Intent intent = new Intent();
            intent.setClass(ContactMeActivity.this, WebViewActivity.class);
            intent.putExtra("webUrl", "https://www.messenger.com/t/Gyroor");
            startActivity(intent);
        }
    }

 

发布了7 篇原创文章 · 获赞 3 · 访问量 5278
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览