[英]Android - How to Send Bundle from One App to Another?
I am working on a cryptography Android application for a course project. 我正在为课程项目开发密码学Android应用程序。 My goal is to be able to send an encrypted message (composed of a key and ciphertext) from my application via a text message.
我的目标是能够通过文本消息从我的应用程序发送加密的消息(由密钥和密文组成)。
I have been trying to send the key and ciphertext as a Bundle, but am running into issues - when I actually attempt to send the Bundle, it is not appearing in the default text messaging app. 我一直试图将密钥和密文作为捆绑包发送,但是遇到了问题-当我实际尝试发送捆绑包时,它没有出现在默认的短信应用程序中。 My code is below and any help/pointing me in the right direction would be greatly appreciated!
我的代码在下面,对我的正确指导将不胜感激!
Thanks! 谢谢!
Intent sendIntent = new Intent();
Bundle extras = new Bundle();
extras.putString("Key", key.getText().toString());
extras.putString("Ciphertext", cipherText.getText().toString());
sendIntent.setAction(Intent.ACTION_SEND);
sendIntent.putExtras(extras);
sendIntent.setType("text/plain");
startActivity(sendIntent);
My goal is to be able to send an encrypted message (composed of a key and ciphertext) from my application via a text message.
我的目标是能够通过文本消息从我的应用程序发送加密的消息(由密钥和密文组成)。
That would be pointless, as then anyone can decrypt the message. 那将毫无意义,因为任何人都可以解密该消息。
when I actually attempt to send the Bundle, it is not appearing in the default text messaging app
当我实际尝试发送捆绑软件时,它没有出现在默认的短信应用程序中
ACTION_SEND
does not support arbitrary extras, such as Key
or Ciphertext
. ACTION_SEND
不支持任意附加功能,例如Key
或Ciphertext
。
The sharing Intent
using ACTION_SEND
follows a specific format in order for the receiving so app to understand the data. 使用
ACTION_SEND
的共享Intent
遵循特定的格式,以便接收的应用程序能够理解数据。 In this case, you would need to provide the message text (your combination of key and cipher text) as an extra using the key Intent.EXTRA_TEXT
. 在这种情况下,您将需要使用密钥
Intent.EXTRA_TEXT
额外提供消息文本(密钥和密文的组合)。 See this page for more details: https://developer.android.com/training/sharing/send.html 请参阅此页面以获取更多详细信息: https : //developer.android.com/training/sharing/send.html
Also, unless that key you are sending is a public key, this is bad practice. 另外,除非您要发送的密钥是公共密钥,否则这是一种不好的做法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.