2016-09-23 2 views
4

Ich entwickle ein Spiel mit libgdx für Android und ios. Ich habe bereits Screenshot mit dieser Funktion erhalten,Wie Screenshot von libgdx Spielpunktzahl in WhatsApp und Facebook teilen?

public void take() { 
    byte[] pixels = ScreenUtils.getFrameBufferPixels(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); 

    Pixmap pixmap = new Pixmap(Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), Pixmap.Format.RGBA8888); 
    BufferUtils.copy(pixels, 0, pixmap.getPixels(), pixels.length); 
    PixmapIO.writePNG(Gdx.files.external("mypixmap.png"), pixmap); 
    pixmap.dispose(); 
} 

Wie kann ich Screenshot in facebook und whatsapp erhalten teilen?

Antwort

1

den Pfad Ihrer ScreenShot bekommen und es wie unten

Intent share = new Intent(Intent.ACTION_SEND); 
share.putExtra(Intent.EXTRA_STREAM, uri); 
share.setType("image/*"); 
share.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); 
context.startActivity(Intent.createChooser(share, "Share image File")); 

Hinweis senden: WhatsApp Bild und Text erhalten nicht beide zusammen.

+0

Danke.Ich denke, dass dieser Code speziell für Android ist. Ich brauche einen Code für libgdx (plattformunabhängig), der sowohl in android als auch in ios funktioniert. – Aju

+3

Das ist nicht möglich. Android und iOS handhaben Absichten unterschiedlich. Sie müssen etwas wie ein [Interface] implementieren (http://stackoverflow.com/questions/39536189/google-sign-in-with-libgdx/39540760#39540760). – Marius

Verwandte Themen