安卓原生開發我們可以使用友盟的ShareSDK或者調用系統的分享,那么在weex開發時,如何實現呢
這里我們就不得不提一下weex的安卓擴展,這里我們調用手機系統的分享。
  @WXModuleAnno(runOnUIThread = true)    public  void share(String msg){        if(mWXSDKInstance.getContext() instanceof  Activity) {            Intent shareIntent = new Intent();            shareIntent.setAction(Intent.ACTION_SEND);            shareIntent.putExtra(Intent.EXTRA_TEXT, msg);            shareIntent.setType("text/plain");            shareIntent.putExtra(Intent.EXTRA_SUBJECT,"好友分享");            shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);            mWXSDKInstance.getContext().startActivity(Intent.createChooser(shareIntent,"分享到"));        }    }寫一個module的擴展,然后再js里面調用  share:function(){                var self = this;                var content = self.jokecontent;                require('@weex-module/myModule').share(content);   }最終效果就是:
項目地址------》點擊打開鏈接
新聞熱點
疑難解答