How to share a file in Android programmatically

前端 未结 4 1211
旧时难觅i
旧时难觅i 2020-12-28 19:28

I want to share a file(.pdf,.apk etc) using share Intent, I searched google but I find only the code for sharing Image

Intent sharingIntent = new Intent(Inte         


        
4条回答
  •  失恋的感觉
    2020-12-28 20:30

    To keep your code pragmatic, use ShareCompat class:

    ShareCompat.IntentBuilder.from(this)
            .setStream(uri)
            .setType(URLConnection.guessContentTypeFromName(file.getName()))
            .startChooser();
    

提交回复
热议问题