发展与&QUOT的Andr​​oid应用程序,共享到"功能 [英] Develop android application with "share-to" functionality

查看:136
本文介绍了发展与&QUOT的Andr​​oid应用程序,共享到"功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望开发其他应用程序接收的文件,将它们转换为PDF格式,并发送PDF到在线API Android应用程序。

I want to develop an android application that receives documents from other apps, converts them to pdf, and sends the pdf to an online API.

我的问题是:如何显示我的应用程序在共享为应用程序可用于大多数Android应用列表?是否有一个在线教程什么地方?

My question is: How do I show my app in the list of "share to" applications that are available to most Android Apps? Is there an online tutorial somewhere?

例如。如果您单击共享为图像上,各种应用程序显示出来(邮件,Gmail中,电子邮件等) - 如何将我的应用程序添加到这个列表

e.g. if you click "share to" on an image, various apps show up (messages, gmail, email, etc) - how do I add my app to this list?

推荐答案

您可以使用

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"));

我刚刚从复制的移动TetPlus 并加了我几条语句太。你可以阅读说明有

I have just copied the code from Mobile TetPlus and added my few statements too. You can read the description there

注意:您必须根据要发送/股数据来设置MIME类型

Note : You have to set your mime type according to the data you want to send/share.

例如

如果你想简单地发送文字然后用纯/文 MIME类型。

If you want to simply send text then use plain/text mime type.

如果您要发送音频文件,然后用音频/ MP3 音频/ 3GP MIME类型。

If you want to send audio files then use audio/mp3 or audio/3gp mime type.

如果您要发送图片文件,然后使用图像/ JPEG 图像/ PNG MIME类型。

If you want to send image files then use image/jpeg or image/png mime type.

这篇关于发展与&QUOT的Andr​​oid应用程序,共享到"功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆