跳轉支付寶掃描二維碼,付款碼,收款碼,和手機計算器,日曆
阿新 • • 發佈:2019-01-26
主要再次做一下記錄,防止以後又重新找一邊。
主要是支付寶跳轉:
//微信 //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(); }
/** * 判斷支付寶是否安裝* @param context * @return */ public static boolean checkAliPayInstalled(Context context) { Uri uri = Uri.parse("alipays://platformapi/startApp"); Intent intent = new Intent(Intent.ACTION_VIEW, uri); ComponentName componentName = intent.resolveActivity(context.getPackageManager()); returncomponentName != null; }
/**開啟計算器*/ public void openJS(){ //可以通過下面方法獲取手機應用 判斷是否存在 PackageInfo pak = getAllApps(getActivity(), "Calculator","calculator"); //大小寫 if(pak != null){ Intent intent = new Intent(); intent = getActivity().getPackageManager().getLaunchIntentForPackage(pak.packageName); startActivity(intent); }else{ Toast.makeText(getActivity(), "未找到計算器", Toast.LENGTH_SHORT).show(); } } public PackageInfo getAllApps(Context context, String app_flag_1, String app_flag_2) { PackageManager pManager = context.getPackageManager(); // 獲取手機內所有應用 List<PackageInfo> packlist = pManager.getInstalledPackages(0); for (int i = 0; i < packlist.size(); i++) { PackageInfo pak = (PackageInfo) packlist.get(i); if(pak.packageName.contains(app_flag_1)||pak.packageName.contains(app_flag_2)){ return pak; } } return null; }
/** * 開啟日曆應用 */ public void gotoCalendarApp(Context cnt) { try { Intent t_intent = new Intent(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(); } }