2016-11-18 92 views
0

数据,我想分享的数据到我的应用程序在WhatsApp的一样: enter image description here入门共享图片和文字

当我在我自己的应用程序,我只得到文本(“退房尝试它。 ..“)。 如何获取其余的数据:图像,标题,描述和网站地址?

Intent intent = getIntent(); 
String action = intent.getAction(); 
String type = intent.getType(); 
if (Intent.ACTION_SEND.equals(action) && type != null) { 
     if ("text/plain".equals(type)) { 
      sharedText = intent.getStringExtra(Intent.EXTRA_TEXT); 
     } else if (type.startsWith("image/")) { 
      handleSendImage(intent); // Handle single image being sent 
     } 
} else if (Intent.ACTION_SEND_MULTIPLE.equals(action) && type != null) { 
     if (type.startsWith("image/")) { 
      handleSendMultipleImages(intent); 
     } 
} 

我只用EXTRA_TEXT得到ACTION_SEND。

+0

该图像是从您共享的链接追加的。 –

+0

@KirankumarZinzuvadia所以我可以在后端采样链接并手动创建? – user1787773

回答

0

您可以通过意图共享图像来流式传输图像。但主要取决于您选择共享的应用程序是否支持图像流共享。

Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.setType("image/jpg"); 
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(photoFile)); 
startActivity(Intent.createChooser(shareIntent, "Share image using")); 

检查该链接以获取有关想法共享选项。

https://guides.codepath.com/android/Sharing-Content-with-Intents

并接收来自其他应用程序共享数据检查此链接:

https://developer.android.com/training/sharing/receive.html

+0

谢谢,但我想从不同的应用程序发送数据。 – user1787773

+0

@ user1787773检查更新的答案 –

0

我做到了,在最后的方法是分析在后端链接的元数据标签和将详细信息发送到应用程序。