Android: Intent.ACTION_SEND分享文件

  /**
     * 共有file
     *
     */
    private fun toShare(file: File) {
        val builder = VmPolicy.Builder()
        StrictMode.setVmPolicy(builder.build())
        var intent = Intent(Intent.ACTION_SEND)
        //二进制的方式传输
        intent.type = "application/octet-stream"
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file))
        intent = Intent.createChooser(intent, " ")
        activity?.startActivity(intent)
    }

 

你可能感兴趣的:(file,android)