首页 > 解决方案 > 如何将文件从我的应用程序发送到另一个支持共享数据的应用程序

问题描述

我实际上是在尝试将来自 API 的数据(作为文本而不是文件)发送给我,并且我想通过许多应用程序将这些数据作为文本文件发送,其中包括共享 WhatsApp、远足等文件,电报、shareit 等

标签: androidandroid-sharing

解决方案


- 你能试试这个代码,看看它是否对你有用:

Intent shareIntent = new Intent("android.intent.action.SEND");
shareIntent.setType("text/plain");               
shareIntent.putExtra("android.intent.extra.SUBJECT",
                     "Codes Easy");              
shareIntent.putExtra("android.intent.extra.SUBJECT",
         "Add a text to be shared here");
startActivity(Intent.createChooser(shareIntent, "Share with"));

推荐阅读