crazecoder / open_file

A plug-in that can call native APP to open files with string result in flutter, support iOS(UTI) / android(intent) / PC(ffi) / web(dart:html)
BSD 3-Clause "New" or "Revised" License
248 stars 431 forks source link

支持支付宝和微信支付功能 #73

Closed didyqian closed 4 years ago

didyqian commented 4 years ago

使用webview的时候应用到微信和支付宝支付功能,自主增加了以下代码,测试成功,建议可以增加此功能,支付功能比较常用。 if (url.startsWith("weixin://wap/pay?")) { try{ Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); activity.startActivity(intent); }catch (Exception e){ Toast.makeText(activity,"未检测到微信,请安装后重试",Toast.LENGTH_SHORT).show(); } // if(isAppAvilible(activity,"com.tencent.mm")){ // // }else{ // } return true; } else if (url.startsWith("alipays:") || url.startsWith("alipay")) { try{ Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); activity.startActivity(intent); }catch (Exception e){ Toast.makeText(activity,"未检测到支付宝,请安装后重试",Toast.LENGTH_SHORT).show(); } return true; } else if (url.contains("intent://platformapi/startapp")) { try{ Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.setComponent(null); // intent.setSelector(null); activity.startActivity(intent); }catch (Exception e){ Toast.makeText(activity,"未检测到支付宝,请安装后重试",Toast.LENGTH_SHORT).show(); } // if(isAppAvilible(activity,"com.eg.android.AlipayGphone")){ // }else{ // Toast.makeText(activity,"尚未安装支付宝",Toast.LENGTH_SHORT).show(); // } return true; }

didyqian commented 4 years ago

不好意思,发错地方了