17

我想实现这样的东西。通过分享

它不应该是硬编码的。如果用户尚未安装 Dropbox,则不应有通过 Dropbox 共享的选项。

提前致谢 !

4

3 回答 3

49

您可以使用以下方法执行相同操作:

Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("text/plain");
i.putExtra(android.content.Intent.EXTRA_SUBJECT,"Subject test");
i.putExtra(android.content.Intent.EXTRA_TEXT, "extra text that you want to put");
startActivity(Intent.createChooser(i,"Share via"));

详细示例在这里供您参考:http: //mobile.tutsplus.com/tutorials/android/android-sdk-implement-a-share-intent/

于 2011-12-29T07:39:29.077 回答
2

通过以下方式共享内容:

Intent shareIntent =  new Intent(android.content.Intent.ACTION_SEND); 

//set type  

shareIntent.setType("text/plain");  

//add what a subject you want

shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT,"add what a subject you want");  

 String shareMessage="message body"; 

//message  

shareIntent.putExtra(android.content.Intent.EXTRA_TEXT,shareMessage); 

//start sharing via 

startActivity(Intent.createChooser(shareIntent,"Sharing via"));  
于 2016-03-25T11:36:23.857 回答
1
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
sharingIntent.putExtra(Intent.EXTRA_TEXT,"Extra text or Link that you want to add");
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Technical Speaks");
startActivity(Intent.createChooser(sharingIntent, "Share via"));

获取完整源代码 点击这里

于 2019-11-04T05:46:39.830 回答