Popups and Pre loaders

Message

To show the message, we should create AndroidMessage object. AndroidMessage has 4 constructors:

public static AndroidMessage Create(string title, string message)
public static AndroidMessage Create(string title, string message, AndroidDialogTheme theme)
public static AndroidMessage Create(string title, string message, string ok)
public static AndroidMessage Create(string title, string message, string ok, AndroidDialogTheme theme)

We can also subscribe to the ActionComplete action, in order to find out when message is closed by user.

Example:

AndroidMessage msg = AndroidMessage.Create("Message Titile", "Message message");
msg.ActionComplete += OnMessageClose;

private void OnMessageClose(AndroidDialogResult result) {
	AN_PoupsProxy.showMessage("Result", "Message Closed");
}

Dialog

The AndroidDialog object has also 4 constructors:

public static AndroidDialog Create(string title, string message)
public static AndroidDialog Create(string title, string message, AndroidDialogTheme theme)
public static AndroidDialog Create(string title, string message, string yes, string no)
public static AndroidDialog Create(string title, string message, string yes, string no, AndroidDialogTheme theme)

With AndroidDialog we can find out not only when a dialog was closed, but also user's replay:

AndroidDialog dialog = AndroidDialog.Create("Dialog Titile", "Dialog message");
dialog.ActionComplete += OnDialogClose;

private void OnDialogClose(AndroidDialogResult result) {
	//parsing result
	switch(result) {
		case AndroidDialogResult.YES:
			Debug.Log ("Yes button pressed");
			break;
		case AndroidDialogResult.NO:
			Debug.Log ("No button pressed");
			break;
	}
			
	AN_PoupsProxy.showMessage("Result", result.ToString() + " button pressed");
}

Rate Us Popup

Rate pop up is commonly used to prompt a user a rate of your app. If the user presses the "Rate" button, he will be redirected to App Store page of your app. If your app has not been released yet, you will see a blank page.

With AndroidRateUsPopUp you will be able to find out a user's replay, but you cannot find out if a user rated your app or got what rating user set to your app.

Besides, rewarding users for rating is restricted by Play Store rules.

The AndroidRateUsPopUp class has the following constructors:

public static AndroidRateUsPopUp Create(string title, string message, string url)
public static AndroidRateUsPopUp Create(string title, string message, string url, AndroidDialogTheme theme)
public static AndroidRateUsPopUp Create(string title, string message, string url, string yes, string later, string no)
public static AndroidRateUsPopUp Create(string title, string message, string url, string yes, string later, string no, AndroidDialogTheme theme)

Example:

private string rateText = "If you enjoy using Google Earth, please take a moment to rate it. Thanks for your support!";
//example link to your app on android market
private string rateUrl = "market://details?id=com.unionassets.android.plugin.preview";

AndroidRateUsPopUp rate = AndroidRateUsPopUp.Create("Rate Us", rateText, rateUrl);
rate.ActionComplete += onRatePopUpClose;

private void OnRatePopUpClose(AndroidDialogResult result) {
    //parsing result
	switch(result) {
		case AndroidDialogResult.RATED:
			Debug.Log ("RATED button pressed");
			break;
		case AndroidDialogResult.REMIND:
			Debug.Log ("REMIND button pressed");
			break;
		case AndroidDialogResult.DECLINED:
			Debug.Log ("DECLINED button pressed");
			break;			
	}

	AN_PoupsProxy.showMessage("Result", result.ToString() + " button pressed");
}

You can also redirect the user to App Store page of your app using:

AndroidNativeUtility.OpenAppRatingPage(string url);

If you need to hide popup, you can use the following method which will hide a currently displayed popup:

AndroidNativeUtility.HideCurrentPopup();

Pre loader

Native preloader can be used pretty simply. Use this code to show the preloader:

To show the preloader, we should use ShowPreloader method.  It has 2 constructors:

public static void ShowPreloader(string title, string message)
public static void ShowPreloader(string title, string message, AndroidDialogTheme theme)

And it can be dismissed with a single function call.

AndroidNativeUtility.HidePreloader();

Note: The user input is disabled while it is preloaded is on the screen.

You can find an example of described API in the AndroidPopUpExamples.cs script.

Example Scene:

Plugins -> StansAssets -> Modules -> AndroidNative -> xExample -> Scenes -> Other -> NativePopUpsEx