2017-03-20 2 views
1

teilen kann ich meine Anwendung will Inhalt (Text und Bild) und für dieses Problem teilen, ich unten Codes schrieb:Wie ich Text und Bild in Android

Intent sharingIntent = new Intent(Intent.ACTION_SEND); 
sharingIntent.setType("*/*"); 
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(content) + "" +"\n\n" + "download us app from this link" + "\n\n" +"https://play.google.com/app/com.example.example"); 
startActivity(Intent.createChooser(sharingIntent, "select app ...")); 

Aber in diesem Code, kann ich nur Teilen Sie Text nicht teilen Bild! Ich möchte Text und Bild teilen.

Für die Anzeige von Text und Bild verwende ich Webview. Ich zeige Bild in Text in webview.

Wie kann ich Text und Bild teilen?

Antwort

5

Der folgende Code ist nützlich, um Text und Bilder mit anderen Apps zu teilen.

String imageToShare = "http://s1.dmcdn.net/hxdt6/x720-qef.jpg"; //Image You wants to share 

String title = "Title to share"; //Title you wants to share 

Intent shareIntent = new Intent(); 
shareIntent.setAction(Intent.ACTION_SEND); 
shareIntent.putExtra(Intent.EXTRA_SUBJECT, title); 
shareIntent.setType("*/*"); 
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
shareIntent.putExtra(Intent.EXTRA_TEXT, imageToShare); 
startActivity(Intent.createChooser(shareIntent, "Select App to Share Text and Image")); 
0

eines code,

Intent intent = new Intent(Intent.ACTION_SEND); 
    intent.setType("image/png"); 
    intent.putExtra(Intent.EXTRA_TEXT,"http://lorempixel.com/400/200/sports/1/");//your Image Url 
    startActivity(Intent.createChooser(intent, "Share Image")); 
+0

Ich möchte Bild aus dem Internet nicht speichern. Wie kann es? –

+0

@KirKoloft, Jetzt habe ich meine Antwort aktualisiert, es funktioniert für mich –

Verwandte Themen