So for android devices there is a default share intent function that you call that will list all the apps that is downloaded on the device with that allows sharing of content. How would I do this using robovm, here is a Screen shot of what I am trying to achieve. Also on a side note, what I want to ultimately do is take a screenshot of their device and post it to whatever social media site the user chooses. Any help would be greatly appreciated :D
RoboVM is deprecated in favor of RoboPods. So, RoboVM is no more, what now?
https://github.com/robovm/robovm-robopods/tree/master
For sharing text
using roboVM, you can set the UIAvtivityViewController
class
NSString textShare = new NSString("This is the text to share");
NSArray texttoshare = new NSArray(textShare);
UIActivityViewController share = new UIActivityViewController(texttoshare,null);
presentViewController(share, true, null);
For sharing text, image and app
, you can do the following code,
NSURL imgUrl = new NSURL(EXTERNAL_IMG_URL);
NSData data = NSData.read(imgUrl);
UIImage image = new UIImage(data);
NSString appStoreUrl = new NSString(APP_STORE_URL);
NSString googleUrl = new NSString(GOOGLE_PLAY_URL);
NSString text = new NSString(TEXT_TO_SHARE);
NSArray<NSObject> texttoshare = new NSArray<NSObject>(text, image, appStoreUrl, googleUrl);
UIActivityViewController share = new UIActivityViewController(
texttoshare, null);
if (UIDevice.getCurrentDevice().getUserInterfaceIdiom() == UIUserInterfaceIdiom.Phone) {
//iPhone
iosApplication.getUIViewController().presentViewController(
share, true, null);
} else {
//iPad
UIPopoverController popover = new UIPopoverController(share);
UIView view = iosApplication.getUIViewController().getView();
CGRect rect = new CGRect(
view.getFrame().getWidth() / 2,
view.getFrame().getHeight() / 4,
0,
0);
popover.presentFromRectInView( rect, view, UIPopoverArrowDirection.Any, true);
}
The following code sends an animated .gif
through Mail and Messenger, however, Twitter only shares a static image.
public void shareGif(String path)
{
NSURL url = new NSURL(new File(path));
NSArray<NSObject> imageArray = new NSArray<NSObject>(image);
UIActivityViewController share = new UIActivityViewController(imageArray,null);
((IOSApplication)Gdx.app).getUIViewController().presentViewController(share, true, null);
}
For generic share in iOS, with text, link and image
the code is given below:
@Override
public void share() {
NSArray<NSObject> items = new NSArray<>(
new NSString("Hey! Check out this mad search engine I use"),
new NSURL("https://www.google.com"),
new UIImage(Gdx.files.external("image.png").file())
);
UIActivityViewController uiActivityViewController = new UIActivityViewController(items, null);
((IOSApplication) Gdx.app).getUIViewController().presentViewController(uiActivityViewController, true, null);
}
It says RoboVM is for iOS only, So how would we use it for android using LibGDX? roboVM with RoboPods is used for iOS while google play services is used for android. Different devices, different code. For android, after integrating the android sdk to your IDE, just link the google play services lib to the android project.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With