How To Activate/Engage with an Android App by calling an Intent

Overview

This guide will describe how to activate/engage with an external Android Application through an intent while running an interview. 

Steps

  1. Create an InIntentInfo object - the first thing is we need to create an intent object which will hold the details of the intent you would like to call.
    The CreateIntentInfo() function returns a class with implementing the IIntentInfo interface:
    public interface IIntentInfo 
    {
          IVariables Extras { get; }
          string PackageName { get; set; } 
          string Action { get; set; }
          int Flags { get; set; }
          string ClassName { get; set; }
          bool SetLaunchIntentForPackage(string inName);
    }
  2. You can launch a general action while specifying that Action name, or you can launch a specific application specifying the PackageName and ClassName etc.
    You can also supply Extras that the activity could use for example to exchange parameters and/or get an outcome of the intent.

    Below you can find an example of creating an InIntentInfo and specifying various parameters:
    var info = CreateIntentInfo();
    then few examples on how you specify the parameters:
    info.Action = "android.media.action.VIDEO_CAPTURE";
    info.PackageName = XXXX;
    info.Extras["incomingparam"] = "Value;
  3. call the intent object you have defined in your script - you can add it either in the Start/End Script.
    StartIntent("AAA", info);
  4. Define what do you want to perform when the intent returns (when it is closed) - In the advanced scripts use the callback OnIntentDone() to define what will be done on the returned value when the application will close.

    function OnIntentDone(inTicket, inCode, inInfo){
          if (inTicket == "AAA") {
               Prompt(inInfo.Extras["outputparm"]);
    Prompt(inTicket);  
          }      
    }

    For example
    : SurveyToGo uses this implementation when we add a multimedia question to capture an image: the action used is to open the camera application and when the image is captured we return the image. 

 

Attached please find a sample survey that will open the camera on the device and set the text when done.

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

Comments

0 comments

Please sign in to leave a comment.