我希望开发一个安卓应用程序,该应用程序可以从其他应用程序接收文档并将其转换为PDF格式,然后将PDF文件发送到在线API。我的问题是:如何将我的应用程序显示在大多数安卓应用程序可用的“分享至”应用程序列表中?是否有在线教程可供参考?例如,如果您在图像上点击“分享至”,则会出现各种应用程序(消息、Gmail、电子邮件等),我该如何将我的应用程序添加到此列表中?
你可以使用
Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
sharingIntent.putExtra(android.content.Intent.EXTRA_EMAIL,new String[]{"abc@def.com,pqr@xyz.com"});
sharingIntent.putExtra(android.content.Intent.EXTRA_STREAM,URI.parse(filePath));
startActivity(Intent.createChooser(sharingIntent, "Share via"));
我想你希望能够在Dialog
中列出你的应用程序。
当调用Share Intent
时,会打开这个Dialog
。
那么,IntentFilter
就是你的方法。
请参考以下链接:
什么是Intent Filter - StackOverflow问题
Android文档