2

I want to share a text like this app does enter image description here

How can I do that?

Boldijar Paul
  • 5,405
  • 9
  • 46
  • 94

2 Answers2

2

There are two steps:

  1. Get from platform-independent Libgdx app code into platform (Android code)
  2. Start the Android Share intent

If you want your platform-independent Libgdx code to be able to call into Android-specific libraries, you generally need to create a small interface or bridge between the platform-independent bits and the platform-specific bits. See https://github.com/libgdx/libgdx/wiki/Interfacing-with-platform-specific-code

Once you're in the platform code, you need to invoke the correct Android Intent API. You did not provide any details about what kind of data you are trying to share (which may change which API you want to use), but see http://developer.android.com/training/sharing/send.html

P.T.
  • 24,557
  • 7
  • 64
  • 95
1

You can spawn native Android processes from libGDX. Just spawn a share intent: http://developer.android.com/training/sharing/shareaction.html

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107
  • Try googling "Android ShareActionProvider". Saying "that code won't work" isn't very useful. Like I said, it's entirely possible to launch native Android processes from libGDX, which is what you need to be looking into. – Kevin Workman Mar 25 '14 at 13:48
  • It's not that simple. He's using libGDX, so android features aren't so readily available. – MPeti Mar 25 '14 at 16:25
  • Yes, they are. For the third time, you can absolutely spawn native Android processes from a libGDX app. – Kevin Workman Mar 25 '14 at 16:26
  • I don't have personal experience in this, but from [this question](http://stackoverflow.com/questions/18854050/launch-android-intent-from-libgdx-render-method) it doesn't seem so.. Has it changed in the last 9 months, am I misunderstanding something or do you disagree with the answers given there? – MPeti Mar 25 '14 at 16:29
  • @MPeti The answers there are about which *thread* to use to launch the Android native stuff, and in fact they say that it's completely possible. [Here](http://staticvoidgames.com/play/?game=46MillionTurkeys) is a Live Wallpaper I created in libGDX which contains a native Android settings window. The process for creating a native Android share window should be the same, and the source is available at that link. – Kevin Workman Mar 25 '14 at 16:35