Android打开第三方APP

360 阅读1分钟

查看包名:adb shell pm list packages

adb shell am monitor,回车,然后启动你想要获取包名的那个应用,即可获得

付款Scheme: **“alipays://platformapi/startapp?appId=20000067”

打开支付宝1:

 try

                {
                    Uri uri = Uri.parse("alipayqr://platformapi/startapp?said=10000007");

                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);

                    startActivity(intent);

                } catch (Exception e)

                {
                      Log.d("aaa","打开失败,请检查是否安装了支付宝");//没有默认的入口 Activity

                }

                    Log.d("aaa","xxxx Activity:");//没有默认的入口 Activity

打开支付宝2:

           try {
                    StringBuffer sb = new StringBuffer("alipays://platformapi/startapp?");
                    String appstring="https://openapi.alipaydev.com/gateway.do?aaaaaa";
                    //*url内容做URLEncoder.encode编码***:不然唤起支付界面失败
                    sb.append("appId=20000067&url=").append(URLEncoder.encode(appstring));
                    Uri uri = Uri.parse(sb.toString());
                    Intent intent = new Intent(Intent.ACTION_VIEW, uri);
                    Log.d("aaa","打开失败,请检查是否安装了支付宝");//没有默认的入口 Activity
                    System.out.println(sb);
                    startActivity(intent);

                } catch (Exception e){
                    e.printStackTrace();
                }