Android Ultimate Plugin tutorial part 2 – sharing Image and URL

Note: this tutorial is outdated please read this link below instead

Hi Guys, in this tutorial i will show you on how easy to share image and text using Android Ultimate Plugin Share Intent.

intent shares
intent shares

Permission needed on your Android Manifest file without this it will not work or it will produce an error.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>  
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_INTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>

First create a variable that will contain the instance of Android Ultimate Plugin Controller.

private AndroidUltimatePluginController androidUltimatePluginController = AndroidUltimatePluginController.GetInstance();

To stop Debug toast message from showing,  pass 0 on SetDebug method

androidUltimatePluginController.SetDebug(0);

Next prepare the screen shot name and screen shot path

string screenShotName = "AndroidUltimateScreenShot.png";
string path = Application.persistentDataPath + "/" + screenShotName;

Take a Screen shot using Utils from our plugin

StartCoroutine(AUP.Utils.TakeScreenshot(path));

Then call “ShareImage” method from Android Ultimate Plugin Controller

and add your subject and subject content

string subject = "Screenshot Test";

string subjectContent = "Testing Screen shot sharing.";

androidUltimatePluginController.ShareImage(subject,subjectContent,path);

Note: when sharing images on Facebook, Facebook app strips strings that’s why you will noticed that your subject and subjectContent does not appear and you need to type again in Facebook before posting.

To share URL just call ShareUrl method

string subject = "Share text";

string subjectContent = "Testing Share text";

string urlToShare = "https://www.google.com";

androidUltimatePluginController.ShareUrl(subject ,subjectContent ,urlToShare );

Here’s some screen for facebook sharing

note: you can share on facebook, twitter, g+ ,gmail and other application that can share images.

FacebookShare
FacebookShare

 

For Reference here’s the actual code that we used on our  Share Image and URL Demo

using UnityEngine;
using System.Collections;

public class ShareAndExperienceDemo : MonoBehaviour {
    
    private AndroidUltimatePluginController androidUltimatePluginController;    
    
    // Use this for initialization
    void Start (){
        androidUltimatePluginController = AndroidUltimatePluginController.GetInstance();
        androidUltimatePluginController.SetDebug(0);
    }    
    
    public void ShareText(){        
        //share link
        androidUltimatePluginController.ShareUrl("my subject","my subject content","https://www.urltoshare.com");
    }

    public void ShareImage(){
        string screenShotName = "AndroidUltimateScreenShot.png";
        string path = Application.persistentDataPath + "/" + screenShotName;

        StartCoroutine(AUP.Utils.TakeScreenshot(path));
        androidUltimatePluginController.ShareImage("subject","subjectContent",path);
    }
}

 

And that’s all!

I hope you find this tutorial helpful

For questions or comments or suggestions or any feed back just email us at gigadrillgames@gmail.com

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.