主要再次做一下记录,防止以后又重新找一边。
主要是支付宝跳转:
//微信//weixin://dl/scan 扫一扫// "weixin://dl/moments"朋友圈//String intentFullUrl ="alipayqr://platformapi/startapp?saId=10000007";//支付宝扫码的uri//String intentFullUrl ="alipayqr://platformapi/startapp?saId=20000056";//支付宝付款吗码的uri String intentFullUrl ="alipays://platformapi/startapp?appId=20000123";//支付宝收款码的uri Intent intent =null;try{intent = Intent.parseUri(intentFullUrl, Intent.URI_INTENT_SCHEME);startActivity(intent);}catch(URISyntaxException e) {e.printStackTrace();}
/*** 判断支付宝是否安装*@paramcontext*@return*/public static booleancheckAliPayInstalled(Context context) {Uri uri = Uri.parse("alipays://platformapi/startApp");Intent intent =newIntent(Intent.ACTION_VIEW, uri);ComponentName componentName = intent.resolveActivity(context.getPackageManager());returncomponentName !=null;}
/**打开计算器*/public voidopenJS(){//可以通过下面方法获取手机应用 判断是否存在 PackageInfo pak = getAllApps(getActivity(),"Calculator","calculator");//大小写if(pak !=null){Intent intent =newIntent();intent = getActivity().getPackageManager().getLaunchIntentForPackage(pak.packageName);startActivity(intent);}else{Toast.makeText(getActivity(),"未找到计算器", Toast.LENGTH_SHORT).show();}}publicPackageInfo getAllApps(Context context, String app_flag_1, String app_flag_2) {PackageManager pManager = context.getPackageManager();// 获取手机内所有应用 List<PackageInfo> packlist = pManager.getInstalledPackages(0);for(inti = 0; i < packlist.size(); i++) {PackageInfo pak = (PackageInfo) packlist.get(i);if(pak.packageName.contains(app_flag_1)||pak.packageName.contains(app_flag_2)){returnpak;}}return null;}
/*** 打开日历应用*/public voidgotoCalendarApp(Context cnt) {try{Intent t_intent =newIntent(Intent.ACTION_VIEW);t_intent.addCategory(Intent.CATEGORY_DEFAULT);t_intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK| Intent.FLAG_ACTIVITY_CLEAR_TASK| Intent.FLAG_ACTIVITY_TASK_ON_HOME);t_intent.setDataAndType(Uri.parse("content://com.android.calendar/"),"time/epoch");cnt.startActivity(t_intent);}catch(Exception e) {e.printStackTrace();Toast.makeText(cnt,"打开日历失败", Toast.LENGTH_SHORT).show();}}