2016-11-18 89 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

我做到了,在最後的方法是分析在後端鏈接的元數據標籤和將詳細信息發送到應用程序。