AdGyde Logo

Sessions


Overview
Android application is a set of Activities and the relationship between application and activities is loose. But in case of Unity, Activities is created by Unity framework therefore only One Activity is created by Android. Still base is android and therefore one of the most common case issues is that the application won't quit after the BACK key is pressed this makes the developers & user confused. AdGyde redefined session to makes it easy to understand.

Definition of session
A session is a conversation between mobile application and user. A session starts with application start and it ends after the user has quit the application. In user’s perspective, pressing BACK key on main activity or click on quit button on the application will initiate application quit, but instead these tasks switch the application to background which is quite hard to understand.

In understanding the MainActivity should be created when user starts the application again, but as application is already in background it just switches background to foreground.

AdGyde redefines quitting of the application - As soon as the user closes the last activity the session is closed. It is exactly in accordance with the user experience with the application. Pressing BACK key on last activity will be considered as the user wants to quit the application.

Scenarios of session
1. End with BACK key
  1. User starts application, session begins
  2. Main activity is created
  3. User presses BACK key
  4. Main activity is destroyed
  5. Session ends

2. Exit by code
  1. User starts application, session begins
  2. Main activity is created
  3. User click on 'quit' button of main activity
  4. Main activity is destroyed
  5. Session ends

3. Switch to background
  1. User starts application, session begins
  2. Main activity is created
  3. User presses HOME key to go to home screen
  4. User click application icon after 45 seconds
  5. Application is brought to front, session is closed, new session begins

  6. Session will be closed if the application was switched to background for more than 30 seconds, as it is assumed that the user switched to another task / application and the application in context is not in use.

4. Killed by system task manager
  1. User starts application, session begins
  2. User presses the HOME key to open system task manager
  3. User kills application with system task manager. Session ends

5. Killed by system
  1. User starts application, Session starts
  2. User switches to another application
  3. Application is running in background; application gets killed by system for low memory. Session ends

Session Integration Steps
In Unity, sessions are not linked to the application Life Cycle and so the session functions need to be executed from unity lifecycle functions.
The AdGyde lifecycle functions which record the sessions need to be liked directly to functions in Unity Lifecycle. Below is the example code where this direct linking is shown

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class Sample_UI_Class : MonoBehaviour {
private static Sample_UI_Class _instance = null;
public static Sample_UI_Class SharedInstance {
get {
// if the instance hasn't been assigned then search for it
if (_instance == null) {
_instance = GameObject.FindObjectOfType(typeof(Sample_UI_Class)) as Sample_UI_Class;
}

return _instance;
}
}

public Text DebugLog;

void Start() {
AdgydeManager.SharedInstance.CallOnStart();
}

void OnApplicationQuit() {
Quit ();
}

void OnApplicationKill() {
Quit ();
}

public void Quit() {
AdgydeManager.SharedInstance.CallOnStop ();
Application.Quit();
}

void OnApplicationPause(bool isPause) {
if (isPause) {
AdgydeManager.SharedInstance.CallOnPause ();
}
else
{
AdgydeManager.SharedInstance.CallOnResume ();
}

IEnumerator CallDelayDestroy (float waitTime) {
// session destroy
AdgydeManager.SharedInstance.CallOnDestroy ();
}
}
}



This website uses cookies in order to improve your experience and our services. By continuing to use our website, agree to the use of such cookies. Click here for Privacy Policy.