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 also has 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 dialog was closed, but also user 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 user rate your app. If the user will press the "Rate" button he will be redirected to App Store page of your app. If you app is not yet released, you will see a blank page.

With AndroidRateUsPopUp, you will be able to find out user replay, but you can not find out is user rated your app or get what rating user set to your app.

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

The AndroidRateUsPopUp  class has 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 also can 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 currently displayed popup:

AndroidNativeUtility.HideCurrentPopup();

Pre loader

Native preloader can be used pretty simple. 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 single function call.

AndroidNativeUtility.HidePreloader();

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

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

Example Scene:

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