i'm using xamarin forms, , in application has button share problem being in android application got doing intent in application ios'm not knowing how do, me?
using android
public async task<bool> share(imagesource image) { intent shareintent = new intent(intent.actionsend); bitmaptoshare = await getbitmap (image); if (bitmaptoshare != null) { createdirectoryforpictures("xpto"); var filepath = system.io.path.combine (dir.absolutepath, string.format("xpto_{0}.png",guid.newguid())); var stream = new filestream (filepath, filemode.create); bitmaptoshare.compress (bitmap.compressformat.png, 100, stream); stream.close (); java.io.file file = new java.io.file (filepath); shareintent.settype ("image/*"); shareintent.putextra (intent.extrastream, android.net.uri.fromfile (file)); shareintent.addflags (activityflags.grantreaduripermission); forms.context.startactivity (intent.createchooser (shareintent, "compartilhar")); } return true; }
private static async task shareimageasyc(imagesource image, string message, string url = null) { var handler = image.gethandler(); if (handler == null) return; var uiimage = await handler.loadimageasync(image); var items = new list<nsobject> { new nsstring(message ?? string.empty) }; if (!url.isnullorempty()) items.add(new nsstring(url)); items.add(uiimage); var controller = new uiactivityviewcontroller(items.toarray(), null); uiapplication.sharedapplication.keywindow.rootviewcontroller.gettopviewcontroller() .presentviewcontroller(controller, true, null); } from: https://github.com/jimbobbennett/jimlib.xamarin/blob/master/jimlib.xamarin.ios/sharing/share.cs
Comments
Post a Comment