private var api: IWXAPI? = null
private var bundle: Bundle? = null
val REQUEST_MEDIA_PROJECTION = 10001
private var mediaProjectionManager: MediaProjectionManager? = null
/**
分享到对话:
SendMessageToWX.Req.WXSceneSession
分享到朋友圈:
SendMessageToWX.Req.WXSceneTimeline;
分享到收藏:
SendMessageToWX.Req.WXSceneFavorite
*/
private val mTargetScene = SendMessageToWX.Req.WXSceneSession
private val mTargetSceneMoments = SendMessageToWX.Req.WXSceneTimeline
首先:
将app注册到微信:
/**
* 将该app注册到微信
*/
api = WXAPIFactory.createWXAPI(this, Constants.APP_ID, false)
api!!.registerApp(Constants.APP_ID)
分享:
val fileObject = WXFileObject(path)
val mediaMessage = WXMediaMessage()
mediaMessage.mediaObject = fileObject
mediaMessage.title = "$title.pdf"
val req = SendMessageToWX.Req()
req.transaction = System.currentTimeMillis().toString() // 设置唯一标识符,用于区分请求
req.message = mediaMessage
req.scene = SendMessageToWX.Req.WXSceneSession // 分享到对话框
api!!.sendReq(req)
微信分享文件夹
最新推荐文章于 2024-04-11 00:25:44 发布